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 :: () => 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
.
Nothing
destruct :: Struct t => t s -> SmallMutableArray# s Any Source
construct :: Struct t => SmallMutableArray# s Any -> t s Source
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
Slots and Fields
A Slot
is a reference to another unboxed mutable object.
Precomposable k k (Slot k k) 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 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
modifyField :: (Struct x, PrimMonad m) => Field x a -> x (PrimState m) -> (a -> a) -> m () Source
modifyField' :: (Struct x, PrimMonad m) => Field x a -> x (PrimState m) -> (a -> a) -> m () Source
class Precomposable t where Source
We can compose slots to get a nested slot or field accessor
Precomposable k * (Field k) Source | |
Precomposable k k (Slot k k) Source |