{-# 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 (forall a b. Ptr a -> Ptr b
castPtr (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 (forall a. FPtr a => Ptr (Raw a) -> a
cast_fptr_to_obj (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 (forall a b. Ptr a -> Ptr b
castPtr (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 (forall a. FPtr a => Ptr (Raw a) -> a
cast_fptr_to_obj (forall a b. Ptr a -> Ptr b
castPtr Ptr RawOstream
x))