{-# 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 tp1 -> Ptr (Raw (List tp1)) get_fptr (List Ptr (RawList tp1) ptr) = Ptr (Raw (List tp1)) Ptr (RawList tp1) ptr cast_fptr_to_obj :: Ptr (Raw (List tp1)) -> List tp1 cast_fptr_to_obj = Ptr (Raw (List tp1)) -> List tp1 Ptr (RawList tp1) -> List tp1 forall tp1. Ptr (RawList tp1) -> List tp1 List instance () => Castable (List tp1) (Ptr (RawList tp1)) where cast :: forall r. List tp1 -> (Ptr (RawList tp1) -> IO r) -> IO r cast List tp1 x Ptr (RawList tp1) -> IO r f = Ptr (RawList tp1) -> IO r f (Ptr (RawList tp1) -> Ptr (RawList tp1) forall a b. Ptr a -> Ptr b castPtr (List tp1 -> Ptr (Raw (List tp1)) forall a. FPtr a => a -> Ptr (Raw a) get_fptr List tp1 x)) uncast :: forall r. Ptr (RawList tp1) -> (List tp1 -> IO r) -> IO r uncast Ptr (RawList tp1) x List tp1 -> IO r f = List tp1 -> IO r f (Ptr (Raw (List tp1)) -> List tp1 forall a. FPtr a => Ptr (Raw a) -> a cast_fptr_to_obj (Ptr (RawList tp1) -> Ptr (RawList tp1) forall a b. Ptr a -> Ptr b castPtr Ptr (RawList tp1) x))