 --          
 --  Created: 19 March 2002
 --
---  Version $Revision: 1.7 $ from $Date: 2003/07/09 22:42:44 $
+--  Version $Revision: 1.8 $ from $Date: 2003/11/02 23:57:07 $
 --
 --  This file is free software; you can redistribute it and/or modify
 --  it under the terms of the GNU General Public License as published by


-- Turn a list of something into a GList.
--
toGList :: [a] -> (a -> Ptr b) -> IO GList
toGList xs conv = makeList nullPtr xs
  where
    -- makeList :: GList -> [a] -> IO GList
    makeList current (x:xs) = do
      newHead <- {#call unsafe list_prepend#} current ((castPtr.conv) x)
      makeList newHead xs
    makeList current [] = return current

--
-- @description@ --------------------------------------------------------------
--
-- * Defines functions to extract data from a GList and to produce a GList from
--   a list of pointers.
--
-- * The same for GSList.
--
-- @documentation@ ------------------------------------------------------------
--
--
-- @todo@ ---------------------------------------------------------------------
--
--
module GList(
  ptrToInt,
  GList,
  fromGList,
  toGList,
  GSList,
  readGSList,
  fromGSList,
  fromGSListRev,
  toGSList
  ) where

import Monad	(liftM)
