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

data RawListIterator tp1

newtype ListIterator tp1 = ListIterator (Ptr (RawListIterator tp1))

class () => IListIterator tp1 where
        deRef :: ListIterator tp1 -> IO tp1
        
        listIteratorPred :: ListIterator tp1 -> IO (ListIterator tp1)
        
        listIteratorSucc :: ListIterator tp1 -> IO (ListIterator tp1)
        
        valid :: ListIterator tp1 -> IO CBool

instance () => FPtr (ListIterator tp1) where
        type Raw (ListIterator tp1) = RawListIterator tp1
        get_fptr (ListIterator ptr) = ptr
        cast_fptr_to_obj = ListIterator

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