shithub: MicroHs

ref: 29161b2a72b72761efb030f9b607c23020ae1ebe
dir: /lib/Foreign/Ptr.hs/

View raw version
module Foreign.Ptr(
  module Foreign.Ptr,
  Ptr,
  FunPtr,
  ) where
import Prelude()              -- do not import Prelude
import Primitives
import Data.Word
import Data.Eq
import Data.Function
import Text.Show

instance forall a . Eq (Ptr a) where
  p == q  =  primPtrEQ p q

instance forall a . Show (Ptr a) where
  showsPrec _ p = showString "PTR#" . showsPrec 0 (primPtrToWord p)

nullPtr :: forall a . Ptr a
nullPtr = primPtrNull

castPtr :: forall a b . Ptr a -> Ptr b
castPtr = primUnsafeCoerce

plusPtr :: forall a b . Ptr a -> Int -> Ptr b
plusPtr = primPtrAdd

minusPtr :: forall a b . Ptr a -> Ptr b -> Int
minusPtr = primPtrSub

--instance forall a . Show (FunPtr a) where
--  showsPrec _ p = showString "FUNPTR#" . showsPrec 0 (primPtrToWord p)