Copyright | (C) 2015 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Unsafe |
Language | Haskell2010 |
- class Struct t where
- data Object s
- destruct :: Struct t => t s -> SmallMutableArray# s Any
- construct :: Struct t => SmallMutableArray# s Any -> t s
- eqStruct :: Struct t => t s -> t s -> Bool
- alloc :: (PrimMonad m, Struct t) => Int -> m (t (PrimState m))
- pattern Nil :: forall t s. Struct t => t s
- isNil :: Struct t => t s -> Bool
- data NullPointerException = NullPointerException
- data Slot x y
- slot :: Int -> Slot s t
- get :: (PrimMonad m, Struct x, Struct y) => Slot x y -> x (PrimState m) -> m (y (PrimState m))
- set :: (PrimMonad m, Struct x, Struct y) => Slot x y -> x (PrimState m) -> y (PrimState m) -> m ()
- data Field x a
- field :: Int -> Field s a
- unboxedField :: Prim a => Int -> Int -> Field s a
- getField :: (PrimMonad m, Struct x) => Field x a -> x (PrimState m) -> m a
- setField :: (PrimMonad m, Struct x) => Field x a -> x (PrimState m) -> a -> m ()
- modifyField :: (Struct x, PrimMonad m) => Field x a -> x (PrimState m) -> (a -> a) -> m ()
- modifyField' :: (Struct x, PrimMonad m) => Field x a -> x (PrimState m) -> (a -> a) -> m ()
- class Precomposable t where
Documentation
An instance for Struct
t
is a witness to the machine-level
equivalence of t
and Object
.
alloc :: (PrimMonad m, Struct t) => Int -> m (t (PrimState m)) Source #
Allocate a structure made out of n
slots. Initialize the structure before proceeding!
Nil
isNil :: Struct t => t s -> Bool Source #
Predicate to check if a struct is Nil
.
>>>
isNil (Nil :: Object (PrimState IO))
True>>>
o <- alloc 1 :: IO (Object (PrimState IO))
>>>
isNil o
False
data NullPointerException Source #
Slots and Fields
A Slot
is a reference to another unboxed mutable object.
Precomposable k k1 (Slot k k1) Source # | |
get :: (PrimMonad m, Struct x, Struct y) => Slot x y -> x (PrimState m) -> m (y (PrimState m)) Source #
Get the value from a Slot
set :: (PrimMonad m, Struct x, Struct y) => Slot x y -> x (PrimState m) -> y (PrimState m) -> m () Source #
Set the value of a Slot
A Field
is a reference from a struct to a normal Haskell data type.
Precomposable * k (Field k) Source # | |
Store the reference to the Haskell data type in a normal field
Store the reference in the nth slot in the nth argument, treated as a MutableByteArray
getField :: (PrimMonad m, Struct x) => Field x a -> x (PrimState m) -> m a Source #
Get the value of a field in a struct
setField :: (PrimMonad m, Struct x) => Field x a -> x (PrimState m) -> a -> m () Source #
Set the value of a field in a struct