Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module defines various helpers used by generated code. Users of the library are not expected to use this module directly.
Synopsis
- handleMethod :: (FromPtr ConstMsg (Cerial ConstMsg t1), MonadCatch m, PrimMonad m, Cerialize a1, ToStruct (MutMsg (PrimState m)) (Cerial (MutMsg (PrimState m)) a1), FromStruct ConstMsg (Cerial ConstMsg a2), MonadSTM m, Decerialize t1, Decerialize a2) => t2 -> (t1 -> t2 -> m a1) -> Maybe (Ptr ConstMsg) -> Fulfiller a2 -> m ()
- isClientFromPtr :: (IsClient a, ReadCtx m msg) => msg -> Maybe (Ptr msg) -> m a
- isClientToPtr :: (IsClient a, WriteCtx m s) => MutMsg s -> a -> m (Maybe (Ptr (MutMsg s)))
Documentation
handleMethod :: (FromPtr ConstMsg (Cerial ConstMsg t1), MonadCatch m, PrimMonad m, Cerialize a1, ToStruct (MutMsg (PrimState m)) (Cerial (MutMsg (PrimState m)) a1), FromStruct ConstMsg (Cerial ConstMsg a2), MonadSTM m, Decerialize t1, Decerialize a2) => t2 -> (t1 -> t2 -> m a1) -> Maybe (Ptr ConstMsg) -> Fulfiller a2 -> m () Source #
isClientFromPtr :: (IsClient a, ReadCtx m msg) => msg -> Maybe (Ptr msg) -> m a Source #
A valid implementation of fromPtr
for any type that implements IsClient
.
GHC gets very confused if we try to just define a single instance
IsClient a => FromPtr msg a
, so instead we define this helper function and
emit a trivial instance for each type from the code generator.
isClientToPtr :: (IsClient a, WriteCtx m s) => MutMsg s -> a -> m (Maybe (Ptr (MutMsg s))) Source #
A valid implementation of toPtr
for any type that implements IsClient
.
See the notes for isClientFromPtr
.