MicroHs-0.8.2.1: lib/Foreign/Ptr.hs
module Foreign.Ptr(Ptr, nullPtr) where
import Primitives(Ptr, primUnsafeCoerce)
import Data.Word
import Data.Eq
import Data.Function
import Text.Show
instance forall a . Eq (Ptr a) where
p == q = primPtrToWord p == primPtrToWord q
instance forall a . Show (Ptr a) where
showsPrec _ p = showString "PTR#" . showsPrec 0 (primPtrToWord p)
nullPtr :: forall a . Ptr a
nullPtr = primWordToPtr 0
castPtr :: forall a b . Ptr a -> Ptr b
castPtr = primUnsafeCoerce
foreign import ccall "plusPtr" c_plusPtr :: forall a . Ptr a -> Int -> IO (Ptr a)
plusPtr :: forall a . Ptr a -> Int -> Ptr a
plusPtr p i = primPerformIO (c_plusPtr p i)
foreign import ccall "minusPtr" c_minusPtr :: forall a . Ptr a -> Ptr a -> IO Int
minusPtr :: forall a . Ptr a -> Ptr a -> Int
minusPtr p q = primPerformIO (c_minusPtr p q)