{-# LANGUAGE FlexibleInstances, FlexibleContexts, TypeFamilies, MultiParamTypeClasses, OverlappingInstances, IncoherentInstances #-} module STD.Ostream.Cast where import Foreign.Ptr import FFICXX.Runtime.Cast import System.IO.Unsafe import STD.Ostream.RawType import STD.Ostream.Interface instance (IOstream a, FPtr a) => Castable (a) (Ptr RawOstream) where cast :: forall r. a -> (Ptr RawOstream -> IO r) -> IO r cast a x Ptr RawOstream -> IO r f = Ptr RawOstream -> IO r f (Ptr (Raw a) -> Ptr RawOstream forall a b. Ptr a -> Ptr b castPtr (a -> Ptr (Raw a) forall a. FPtr a => a -> Ptr (Raw a) get_fptr a x)) uncast :: forall r. Ptr RawOstream -> (a -> IO r) -> IO r uncast Ptr RawOstream x a -> IO r f = a -> IO r f (Ptr (Raw a) -> a forall a. FPtr a => Ptr (Raw a) -> a cast_fptr_to_obj (Ptr RawOstream -> Ptr (Raw a) forall a b. Ptr a -> Ptr b castPtr Ptr RawOstream x)) instance () => Castable (Ostream) (Ptr RawOstream) where cast :: forall r. Ostream -> (Ptr RawOstream -> IO r) -> IO r cast Ostream x Ptr RawOstream -> IO r f = Ptr RawOstream -> IO r f (Ptr RawOstream -> Ptr RawOstream forall a b. Ptr a -> Ptr b castPtr (Ostream -> Ptr (Raw Ostream) forall a. FPtr a => a -> Ptr (Raw a) get_fptr Ostream x)) uncast :: forall r. Ptr RawOstream -> (Ostream -> IO r) -> IO r uncast Ptr RawOstream x Ostream -> IO r f = Ostream -> IO r f (Ptr (Raw Ostream) -> Ostream forall a. FPtr a => Ptr (Raw a) -> a cast_fptr_to_obj (Ptr RawOstream -> Ptr RawOstream forall a b. Ptr a -> Ptr b castPtr Ptr RawOstream x))