Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- readField :: forall k a b mut m. (IsStruct a, ReadCtx m mut) => Field k a b -> Raw a mut -> m (Raw b mut)
- getField :: (IsStruct a, ReprFor b ~ 'Data sz, Parse b bp) => Field 'Slot a b -> Raw a 'Const -> bp
- setField :: forall a b m s. (IsStruct a, RWCtx m s) => Field 'Slot a b -> Raw b ('Mut s) -> Raw a ('Mut s) -> m ()
- newField :: forall a b m s. (IsStruct a, Allocate b, RWCtx m s) => Field 'Slot a b -> AllocHint b -> Raw a ('Mut s) -> m (Raw b ('Mut s))
- hasField :: (ReadCtx m mut, IsStruct a, IsPtr b) => Field 'Slot a b -> Raw a mut -> m Bool
- encodeField :: forall a b m s bp. (IsStruct a, Parse b bp, RWCtx m s) => Field 'Slot a b -> bp -> Raw a ('Mut s) -> m ()
- parseField :: (IsStruct a, Parse b bp, ReadCtx m 'Const) => Field k a b -> Raw a 'Const -> m bp
- setVariant :: forall a b m s. (HasUnion a, RWCtx m s) => Variant 'Slot a b -> Raw a ('Mut s) -> Raw b ('Mut s) -> m ()
- initVariant :: forall a b m s. (HasUnion a, RWCtx m s) => Variant 'Group a b -> Raw a ('Mut s) -> m (Raw b ('Mut s))
- encodeVariant :: forall a b m s bp. (HasUnion a, Parse b bp, RWCtx m s) => Variant 'Slot a b -> bp -> Raw a ('Mut s) -> m ()
- structWhich :: forall a mut m. (ReadCtx m mut, HasUnion a) => Raw a mut -> m (RawWhich a mut)
- unionWhich :: forall a mut m. (ReadCtx m mut, HasUnion a) => Raw (Which a) mut -> m (RawWhich a mut)
- structUnion :: HasUnion a => Raw a mut -> Raw (Which a) mut
- unionStruct :: HasUnion a => Raw (Which a) mut -> Raw a mut
Documentation
readField :: forall k a b mut m. (IsStruct a, ReadCtx m mut) => Field k a b -> Raw a mut -> m (Raw b mut) Source #
Read the value of a field of a struct.
getField :: (IsStruct a, ReprFor b ~ 'Data sz, Parse b bp) => Field 'Slot a b -> Raw a 'Const -> bp Source #
Like readField
, but:
- Doesn't need the monadic context; can be used in pure code.
- Only works for immutable values.
- Only works for fields in the struct's data section.
setField :: forall a b m s. (IsStruct a, RWCtx m s) => Field 'Slot a b -> Raw b ('Mut s) -> Raw a ('Mut s) -> m () Source #
Set a struct field to a value. Not usable for group fields.
newField :: forall a b m s. (IsStruct a, Allocate b, RWCtx m s) => Field 'Slot a b -> AllocHint b -> Raw a ('Mut s) -> m (Raw b ('Mut s)) Source #
Allocate space for the value of a field, and return it.
hasField :: (ReadCtx m mut, IsStruct a, IsPtr b) => Field 'Slot a b -> Raw a mut -> m Bool Source #
Return whether the specified field is present. Only applicable for pointer fields.
encodeField :: forall a b m s bp. (IsStruct a, Parse b bp, RWCtx m s) => Field 'Slot a b -> bp -> Raw a ('Mut s) -> m () Source #
Marshal a parsed value into a struct's field.
parseField :: (IsStruct a, Parse b bp, ReadCtx m 'Const) => Field k a b -> Raw a 'Const -> m bp Source #
parse a struct's field and return its parsed form.
setVariant :: forall a b m s. (HasUnion a, RWCtx m s) => Variant 'Slot a b -> Raw a ('Mut s) -> Raw b ('Mut s) -> m () Source #
Set the struct's anonymous union to the given variant, with the
supplied value as its argument. Not applicable for variants whose
argument is a group; use initVariant
instead.
initVariant :: forall a b m s. (HasUnion a, RWCtx m s) => Variant 'Group a b -> Raw a ('Mut s) -> m (Raw b ('Mut s)) Source #
Set the struct's anonymous union to the given variant, returning
the variant's argument, which must be a group (for non-group fields,
use setVariant
or encodeVariant
.
encodeVariant :: forall a b m s bp. (HasUnion a, Parse b bp, RWCtx m s) => Variant 'Slot a b -> bp -> Raw a ('Mut s) -> m () Source #
Set the struct's anonymous union to the given variant, marshalling
the supplied value into the message to be its argument. Not applicable
for variants whose argument is a group; use initVariant
instead.
structWhich :: forall a mut m. (ReadCtx m mut, HasUnion a) => Raw a mut -> m (RawWhich a mut) Source #
Get a non-opaque view on the struct's anonymous union, which can be used to pattern match on.
unionWhich :: forall a mut m. (ReadCtx m mut, HasUnion a) => Raw (Which a) mut -> m (RawWhich a mut) Source #
Get a non-opaque view on the anonymous union, which can be used to pattern match on.