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 'Const (Cerial 'Const t1), MonadCatch m, PrimMonad m, Cerialize (PrimState m) a1, ToStruct ('Mut (PrimState m)) (Cerial ('Mut (PrimState m)) a1), FromStruct 'Const (Cerial 'Const a2), MonadSTM m, Decerialize t1, Decerialize a2) => t2 -> (t1 -> t2 -> m a1) -> Maybe (Ptr 'Const) -> Fulfiller a2 -> m ()
- isClientFromPtr :: (IsClient a, ReadCtx m mut) => Message mut -> Maybe (Ptr mut) -> m a
- isClientToPtr :: (IsClient a, WriteCtx m s) => Message ('Mut s) -> a -> m (Maybe (Ptr ('Mut s)))
Documentation
handleMethod :: (FromPtr 'Const (Cerial 'Const t1), MonadCatch m, PrimMonad m, Cerialize (PrimState m) a1, ToStruct ('Mut (PrimState m)) (Cerial ('Mut (PrimState m)) a1), FromStruct 'Const (Cerial 'Const a2), MonadSTM m, Decerialize t1, Decerialize a2) => t2 -> (t1 -> t2 -> m a1) -> Maybe (Ptr 'Const) -> Fulfiller a2 -> m () Source #
isClientFromPtr :: (IsClient a, ReadCtx m mut) => Message mut -> Maybe (Ptr mut) -> 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.