on master help sign in
Document Trans.Dispatch and Trans.Tagged
e60f5a4Index Int
src/Control/Monad/Ether.hs+1−1
@@ -10,5 +10,5 @@ import Control.Monad.Ether.Reader as X
10import Control.Monad.Ether.Writer as X
10import Control.Monad.Ether.Writer as X
11import Control.Monad.Ether.State as X
11import Control.Monad.Ether.State as X
12import Control.Monad.Ether.Except as X
12import Control.Monad.Ether.Except as X
13−import Control.Monad.Trans.Ether.Dispatch as X hiding (pack, unpack)
13+import Control.Monad.Trans.Ether.Dispatch as X
14import Control.Ether.TH as X (ethereal)
14import Control.Ether.TH as X (ethereal)
src/Control/Monad/Ether/Implicit.hs+1−1
@@ -10,5 +10,5 @@ import Control.Monad.Ether.Implicit.Reader as X
10import Control.Monad.Ether.Implicit.Writer as X
10import Control.Monad.Ether.Implicit.Writer as X
11import Control.Monad.Ether.Implicit.State as X
11import Control.Monad.Ether.Implicit.State as X
12import Control.Monad.Ether.Implicit.Except as X
12import Control.Monad.Ether.Implicit.Except as X
13−import Control.Monad.Trans.Ether.Dispatch as X hiding (pack, unpack)
13+import Control.Monad.Trans.Ether.Dispatch as X
14import Control.Ether.TH as X (ethereal)
14import Control.Ether.TH as X (ethereal)
src/Control/Monad/Trans/Ether/Dispatch.hs+28−3
@@ -16,6 +16,34 @@
16
16
17{- |
17{- |
18
18
19+Type-level machinery to manipulate constraints on the monad
20+transformer stack.
21+
22+Out of the box it provides the following dispatch strategies:
23+
24+* 'tagAttach' to use functions defined using untagged monad classes
25+ as if they were defined using tagged ones.
26+
27+* 'tagReplace' to use functions defined using one tag
28+ as if they were defined using another one.
29+
30+> import qualified Control.Monad.State as T
31+> import Control.Ether.TH (ethereal)
32+> import Control.Monad.Ether.State (MonadState)
33+> import Control.Monad.Trans.Ether.Dispatch (tagAttach, tagDispatch)
34+>
35+> ethereal "Foo" "foo"
36+> ethereal "Bar" "bar"
37+>
38+> f :: T.MonadState Int m => m String
39+> f = fmap show T.get
40+>
41+> g :: MonadState Foo Int m => m String
42+> g = tagAttach foo f
43+>
44+> h :: MonadState Bar Int m => m String
45+> h = tagReplace foo bar g
46+
19-}
47-}
20
48
21module Control.Monad.Trans.Ether.Dispatch
49module Control.Monad.Trans.Ether.Dispatch
@@ -27,9 +55,6 @@ module Control.Monad.Trans.Ether.Dispatch
27 , K_TagReplace(..)
55 , K_TagReplace(..)
28 , tagAttach
56 , tagAttach
29 , tagReplace
57 , tagReplace
30− -- * Newtype operations
31− , pack
32− , unpack
33 ) where
58 ) where
34
59
35import Control.Applicative
60import Control.Applicative
src/Control/Monad/Trans/Ether/Tagged.hs+3−3
@@ -7,9 +7,9 @@
7{-# LANGUAGE ConstraintKinds #-}
7{-# LANGUAGE ConstraintKinds #-}
8{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE TypeFamilies #-}
9
9
10−{- |
10+-- | This module defines the core data type of Ether, 'TaggedTrans',
11−
11+-- and a bunch of instances for it. 'TaggedTrans' attaches a tag to
12−-}
12+-- an existing monad transformer.
13
13
14module Control.Monad.Trans.Ether.Tagged where
14module Control.Monad.Trans.Ether.Tagged where
15
15