{-# LANGUAGE EmptyDataDecls, FlexibleInstances,
  MultiParamTypeClasses, TypeFamilies #-}
module OGDF.List.Template where
import Foreign.C.Types
import Foreign.Ptr
import FFICXX.Runtime.Cast
import OGDF.ListIterator.Template

data RawList tp1

newtype List tp1 = List (Ptr (RawList tp1))

class () => IList tp1 where
        begin :: List tp1 -> IO (ListIterator tp1)
        
        end :: List tp1 -> IO (ListIterator tp1)
        
        pushBack :: List tp1 -> tp1 -> IO (ListIterator tp1)

instance () => FPtr (List tp1) where
        type Raw (List tp1) = RawList tp1
        get_fptr (List ptr) = ptr
        cast_fptr_to_obj = List

instance () => Castable (List tp1) (Ptr (RawList tp1)) where
        cast x f = f (castPtr (get_fptr x))
        uncast x f = f (cast_fptr_to_obj (castPtr x))
