on master help sign in
Document Trans.Dispatch and Trans.Tagged

closes #11

commite60f5a44b14314cedf1ba37df62f6cac5d91cdf9 authorIndex Int <vlad.z.4096@gmail.com> dateSat 30 Jan 2016, 15:36 (11 years ago) parent1db55d8
4 files changed+33−8
src/Control/Monad/Ether.hs+1−1 src/Control/Monad/Ether/Implicit.hs+1−1 src/Control/Monad/Trans/Ether/Dispatch.hs+28−3 src/Control/Monad/Trans/Ether/Tagged.hs+3−3
src/Control/Monad/Ether.hs+1−1
@@ -10,5 +10,5 @@ import Control.Monad.Ether.Reader as X
1010import Control.Monad.Ether.Writer as X
1111import Control.Monad.Ether.State as X
1212import 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
1414import 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
1010import Control.Monad.Ether.Implicit.Writer as X
1111import Control.Monad.Ether.Implicit.State as X
1212import 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
1414import Control.Ether.TH as X (ethereal)
src/Control/Monad/Trans/Ether/Dispatch.hs+28−3
@@ -16,6 +16,34 @@
1616
1717{- |
1818
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+
1947-}
2048
2149module Control.Monad.Trans.Ether.Dispatch
@@ -27,9 +55,6 @@ module Control.Monad.Trans.Ether.Dispatch
2755 , K_TagReplace(..)
2856 , tagAttach
2957 , tagReplace
30− -- * Newtype operations
31− , pack
32− , unpack
3358 ) where
3459
3560import Control.Applicative
src/Control/Monad/Trans/Ether/Tagged.hs+3−3
@@ -7,9 +7,9 @@
77{-# LANGUAGE ConstraintKinds #-}
88{-# LANGUAGE TypeFamilies #-}
99
10−{- |
11−
12−-}
10+-- | This module defines the core data type of Ether, 'TaggedTrans',
11+-- and a bunch of instances for it. 'TaggedTrans' attaches a tag to
12+-- an existing monad transformer.
1313
1414module Control.Monad.Trans.Ether.Tagged where
1515