Copyright | (C) 2015 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <[email protected]> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Unsafe |
Language | Haskell2010 |
Data.Struct
Contents
Description
Synopsis
- class Struct (t :: Type -> Type) where
- data Object s
- destruct :: Struct t => t s -> SmallMutableArray# s (Any :: Type)
- construct :: Struct t => SmallMutableArray# s (Any :: Type) -> 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 :: k) (y :: k1)
- slot :: forall {k1} {k2} (s :: k1) (t :: k2). 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 :: k) a
- field :: forall {k} (s :: k) a. Int -> Field s a
- unboxedField :: forall {k} a (s :: k). 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 :: k -> k1 -> Type) where
Documentation
class Struct (t :: Type -> Type) where Source #
An instance for Struct
t
is a witness to the machine-level
equivalence of t
and Object
.
Minimal complete definition
Nothing
Methods
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 #
Constructors
NullPointerException |
Instances
Exception NullPointerException Source # | |
Defined in Data.Struct.Internal Methods toException :: NullPointerException -> SomeException # fromException :: SomeException -> Maybe NullPointerException # | |
Show NullPointerException Source # | |
Defined in Data.Struct.Internal Methods showsPrec :: Int -> NullPointerException -> ShowS # show :: NullPointerException -> String # showList :: [NullPointerException] -> ShowS # |
Slots and Fields
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
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
modifyField' :: (Struct x, PrimMonad m) => Field x a -> x (PrimState m) -> (a -> a) -> m () Source #
class Precomposable (t :: k -> k1 -> Type) where Source #
We can compose slots to get a nested slot or field accessor