Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Monad.Trans.Ether.Dispatch
Description
Type-level machinery to manipulate constraints on the monad transformer stack.
Out of the box it provides the following dispatch strategies:
tagAttach
to use functions defined using untagged monad classes as if they were defined using tagged ones.tagReplace
to use functions defined using one tag as if they were defined using another one.
import qualified Control.Monad.State as T import Control.Ether.TH (ethereal) import Control.Monad.Ether.State (MonadState) import Control.Monad.Trans.Ether.Dispatch (tagAttach, tagDispatch) ethereal "Foo" "foo" ethereal "Bar" "bar" f :: T.MonadState Int m => m String f = fmap show T.get g :: MonadState Foo Int m => m String g = tagAttach foo f h :: MonadState Bar Int m => m String h = tagReplace foo bar g
- data DispatchT dp m a
- data K_TagAttach t = TagAttach t
- data K_TagReplace tOld tNew = TagReplace tOld tNew
- tagAttach :: proxy t -> DispatchTagAttachT t m a -> m a
- tagReplace :: proxy tOld -> proxy tNew -> DispatchTagReplaceT tOld tNew m a -> m a
The DispatchT monad transformer
Wrap a monad to change its tags. Under the hood this is
simply IdentityT
, all the work is happening on the type level.
Instances
Dispatch types and functions
data K_TagReplace tOld tNew Source
Encode type-level information for tagReplace
.
Constructors
TagReplace tOld tNew |
tagAttach :: proxy t -> DispatchTagAttachT t m a -> m a Source
Attach a tag to untagged transformers.
tagReplace :: proxy tOld -> proxy tNew -> DispatchTagReplaceT tOld tNew m a -> m a Source
Replace a tag with another tag.