on master help sign in
Proper name for TaggedTrans
1db55d8Index Int
CHANGELOG.md+1
@@ -4,6 +4,7 @@
4* Poly-kinded tags.
4* Poly-kinded tags.
5* Remove `Control.Ether.Tagged`.
5* Remove `Control.Ether.Tagged`.
6* Replace `Control.Ether.Wrapped` with `Control.Monad.Trans.Ether.Dispatch`.
6* Replace `Control.Ether.Wrapped` with `Control.Monad.Trans.Ether.Dispatch`.
7+* Unified tagged transformer type in `Control.Monad.Trans.Ether.Tagged`.
7* `MonadThrow`, `MonadCatch`, `MonadMask` instances.
8* `MonadThrow`, `MonadCatch`, `MonadMask` instances.
8* Drop `newtype-generics`.
9* Drop `newtype-generics`.
9* Instance search is now more strict.
10* Instance search is now more strict.
ether.cabal+1−1
@@ -27,7 +27,6 @@ library
27 exposed-modules: Control.Ether.Abbr
27 exposed-modules: Control.Ether.Abbr
28 Control.Ether.Implicit.Abbr
28 Control.Ether.Implicit.Abbr
29 Control.Ether.TH
29 Control.Ether.TH
30− Control.Ether.TT
31 Control.Monad.Trans.Ether.Reader
30 Control.Monad.Trans.Ether.Reader
32 Control.Monad.Trans.Ether.Writer
31 Control.Monad.Trans.Ether.Writer
33 Control.Monad.Trans.Ether.State
32 Control.Monad.Trans.Ether.State
@@ -35,6 +34,7 @@ library
35 Control.Monad.Trans.Ether.State.Strict
34 Control.Monad.Trans.Ether.State.Strict
36 Control.Monad.Trans.Ether.Except
35 Control.Monad.Trans.Ether.Except
37 Control.Monad.Trans.Ether.Dispatch
36 Control.Monad.Trans.Ether.Dispatch
37+ Control.Monad.Trans.Ether.Tagged
38 Control.Monad.Ether
38 Control.Monad.Ether
39 Control.Monad.Ether.Reader
39 Control.Monad.Ether.Reader
40 Control.Monad.Ether.Reader.Class
40 Control.Monad.Ether.Reader.Class
src/Control/Monad/Trans/Ether/Except.hs+2−2
@@ -26,7 +26,7 @@ module Control.Monad.Trans.Ether.Except
26
26
27import Data.Functor.Identity (Identity(..))
27import Data.Functor.Identity (Identity(..))
28import qualified Control.Monad.Trans.Except as Trans
28import qualified Control.Monad.Trans.Except as Trans
29−import Control.Ether.TT
29+import Control.Monad.Trans.Ether.Tagged
30
30
31
31
32-- | The parameterizable exception monad.
32-- | The parameterizable exception monad.
@@ -45,7 +45,7 @@ runExcept _ = Trans.runExcept . unpack
45--
45--
46-- The 'return' function returns a normal value, while '>>=' exits on
46-- The 'return' function returns a normal value, while '>>=' exits on
47-- the first exception.
47-- the first exception.
48−type ExceptT tag e = TT tag (Trans.ExceptT e)
48+type ExceptT tag e = TaggedTrans tag (Trans.ExceptT e)
49
49
50-- | Constructor for computations in the exception monad transformer.
50-- | Constructor for computations in the exception monad transformer.
51exceptT :: proxy tag -> m (Either e a) -> ExceptT tag e m a
51exceptT :: proxy tag -> m (Either e a) -> ExceptT tag e m a
src/Control/Monad/Trans/Ether/Reader.hs+2−2
@@ -26,7 +26,7 @@ module Control.Monad.Trans.Ether.Reader
26
26
27import Data.Functor.Identity (Identity(..))
27import Data.Functor.Identity (Identity(..))
28import qualified Control.Monad.Trans.Reader as Trans
28import qualified Control.Monad.Trans.Reader as Trans
29−import Control.Ether.TT
29+import Control.Monad.Trans.Ether.Tagged
30
30
31-- | The parameterizable reader monad.
31-- | The parameterizable reader monad.
32--
32--
@@ -41,7 +41,7 @@ type Reader tag r = ReaderT tag r Identity
41--
41--
42-- The 'return' function ignores the environment, while '>>=' passes
42-- The 'return' function ignores the environment, while '>>=' passes
43-- the inherited environment to both subcomputations.
43-- the inherited environment to both subcomputations.
44−type ReaderT tag r = TT tag (Trans.ReaderT r)
44+type ReaderT tag r = TaggedTrans tag (Trans.ReaderT r)
45
45
46-- | Constructor for computations in the reader monad transformer.
46-- | Constructor for computations in the reader monad transformer.
47readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a
47readerT :: proxy tag -> (r -> m a) -> ReaderT tag r m a
src/Control/Monad/Trans/Ether/State/Lazy.hs+2−2
@@ -30,7 +30,7 @@ module Control.Monad.Trans.Ether.State.Lazy
30
30
31import Data.Functor.Identity (Identity(..))
31import Data.Functor.Identity (Identity(..))
32import qualified Control.Monad.Trans.State.Lazy as Trans
32import qualified Control.Monad.Trans.State.Lazy as Trans
33−import Control.Ether.TT
33+import Control.Monad.Trans.Ether.Tagged
34
34
35-- | The parametrizable state monad.
35-- | The parametrizable state monad.
36--
36--
@@ -44,7 +44,7 @@ type State tag r = StateT tag r Identity
44--
44--
45-- The 'return' function leaves the state unchanged, while '>>=' uses
45-- The 'return' function leaves the state unchanged, while '>>=' uses
46-- the final state of the first computation as the initial state of the second.
46-- the final state of the first computation as the initial state of the second.
47−type StateT tag s = TT tag (Trans.StateT s)
47+type StateT tag s = TaggedTrans tag (Trans.StateT s)
48
48
49-- | Constructor for computations in the state monad transformer.
49-- | Constructor for computations in the state monad transformer.
50stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
50stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
src/Control/Monad/Trans/Ether/State/Strict.hs+2−2
@@ -30,7 +30,7 @@ module Control.Monad.Trans.Ether.State.Strict
30
30
31import Data.Functor.Identity (Identity(..))
31import Data.Functor.Identity (Identity(..))
32import qualified Control.Monad.Trans.State.Strict as Trans
32import qualified Control.Monad.Trans.State.Strict as Trans
33−import Control.Ether.TT
33+import Control.Monad.Trans.Ether.Tagged
34
34
35-- | The parametrizable state monad.
35-- | The parametrizable state monad.
36--
36--
@@ -44,7 +44,7 @@ type State tag r = StateT tag r Identity
44--
44--
45-- The 'return' function leaves the state unchanged, while '>>=' uses
45-- The 'return' function leaves the state unchanged, while '>>=' uses
46-- the final state of the first computation as the initial state of the second.
46-- the final state of the first computation as the initial state of the second.
47−type StateT tag s = TT tag (Trans.StateT s)
47+type StateT tag s = TaggedTrans tag (Trans.StateT s)
48
48
49-- | Constructor for computations in the state monad transformer.
49-- | Constructor for computations in the state monad transformer.
50stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
50stateT :: proxy tag -> (s -> m (a, s)) -> StateT tag s m a
src/Control/Ether/TT.hs → src/Control/Monad/Trans/Ether/Tagged.hsrenamed+28−33
@@ -6,7 +6,12 @@
6{-# LANGUAGE UndecidableInstances #-}
6{-# LANGUAGE UndecidableInstances #-}
7{-# LANGUAGE ConstraintKinds #-}
7{-# LANGUAGE ConstraintKinds #-}
8{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE TypeFamilies #-}
9+
10+{- |
11+
12+-}
13+
9−module Control.Ether.TT where
14+module Control.Monad.Trans.Ether.Tagged where
10
15
11import Control.Applicative
16import Control.Applicative
12import Control.Monad (MonadPlus)
17import Control.Monad (MonadPlus)
@@ -38,44 +43,34 @@ import Data.Coerce (coerce)
38import Control.Ether.Util (MonadApplicative)
43import Control.Ether.Util (MonadApplicative)
39
44
40-- | Tagged monad transformer.
45-- | Tagged monad transformer.
41−newtype TT tag trans (m :: * -> *) a = TT (trans m a)
46+newtype TaggedTrans tag trans (m :: * -> *) a = TaggedTrans (trans m a)
42 deriving
47 deriving
43 ( Generic
48 ( Generic
44− , Functor
45− , Applicative
49+ , Functor, Applicative, Alternative, Monad, MonadPlus
46− , Alternative
47− , Monad
48− , MonadPlus
49− , MonadFix
50− , MonadTrans
50+ , MonadFix, MonadTrans, MonadIO, MFunctor, MMonad
51− , MonadIO
52− , MFunctor
53− , MMonad
54− , MonadThrow
51+ , MonadThrow, MonadCatch, MonadMask )
55− , MonadCatch
56− , MonadMask )
57
52
58-- | Type-restricted 'coerce'.
53-- | Type-restricted 'coerce'.
59−pack :: trans m a -> TT tag trans m a
54+pack :: trans m a -> TaggedTrans tag trans m a
60pack = coerce
55pack = coerce
61
56
62-- | Type-restricted 'coerce'.
57-- | Type-restricted 'coerce'.
63−unpack :: TT tag trans m a -> trans m a
58+unpack :: TaggedTrans tag trans m a -> trans m a
64unpack = coerce
59unpack = coerce
65
60
66instance
61instance
67 ( MB.MonadBase b m
62 ( MB.MonadBase b m
68 , MonadTrans trans
63 , MonadTrans trans
69 , MonadApplicative (trans m)
64 , MonadApplicative (trans m)
70− ) => MB.MonadBase b (TT tag trans m)
65+ ) => MB.MonadBase b (TaggedTrans tag trans m)
71 where
66 where
72 liftBase = MB.liftBaseDefault
67 liftBase = MB.liftBaseDefault
73
68
74instance
69instance
75 ( MC.MonadTransControl trans
70 ( MC.MonadTransControl trans
76− ) => MC.MonadTransControl (TT tag trans)
71+ ) => MC.MonadTransControl (TaggedTrans tag trans)
77 where
72 where
78− type StT (TT tag trans) a = MC.StT trans a
73+ type StT (TaggedTrans tag trans) a = MC.StT trans a
79 liftWith = MC.defaultLiftWith pack unpack
74 liftWith = MC.defaultLiftWith pack unpack
80 restoreT = MC.defaultRestoreT pack
75 restoreT = MC.defaultRestoreT pack
81
76
@@ -83,27 +78,27 @@ instance
83 ( MC.MonadBaseControl b m
78 ( MC.MonadBaseControl b m
84 , MC.MonadTransControl trans
79 , MC.MonadTransControl trans
85 , MonadApplicative (trans m)
80 , MonadApplicative (trans m)
86− ) => MC.MonadBaseControl b (TT tag trans m)
81+ ) => MC.MonadBaseControl b (TaggedTrans tag trans m)
87 where
82 where
88− type StM (TT tag trans m) a = MC.ComposeSt trans m a
83+ type StM (TaggedTrans tag trans m) a = MC.ComposeSt trans m a
89 liftBaseWith = MC.defaultLiftBaseWith
84 liftBaseWith = MC.defaultLiftBaseWith
90 restoreM = MC.defaultRestoreM
85 restoreM = MC.defaultRestoreM
91
86
92−type instance Lift.StT (TT tag trans) a = Lift.StT trans a
87+type instance Lift.StT (TaggedTrans tag trans) a = Lift.StT trans a
93
88
94−instance Lift.LiftLocal trans => Lift.LiftLocal (TT tag trans) where
89+instance Lift.LiftLocal trans => Lift.LiftLocal (TaggedTrans tag trans) where
95 liftLocal = Lift.defaultLiftLocal pack unpack
90 liftLocal = Lift.defaultLiftLocal pack unpack
96
91
97−instance Lift.LiftCatch trans => Lift.LiftCatch (TT tag trans) where
92+instance Lift.LiftCatch trans => Lift.LiftCatch (TaggedTrans tag trans) where
98 liftCatch = Lift.defaultLiftCatch pack unpack
93 liftCatch = Lift.defaultLiftCatch pack unpack
99
94
100−instance Lift.LiftListen trans => Lift.LiftListen (TT tag trans) where
95+instance Lift.LiftListen trans => Lift.LiftListen (TaggedTrans tag trans) where
101 liftListen = Lift.defaultLiftListen pack unpack
96 liftListen = Lift.defaultLiftListen pack unpack
102
97
103−instance Lift.LiftPass trans => Lift.LiftPass (TT tag trans) where
98+instance Lift.LiftPass trans => Lift.LiftPass (TaggedTrans tag trans) where
104 liftPass = Lift.defaultLiftPass pack unpack
99 liftPass = Lift.defaultLiftPass pack unpack
105
100
106−instance Lift.LiftCallCC trans => Lift.LiftCallCC (TT tag trans) where
101+instance Lift.LiftCallCC trans => Lift.LiftCallCC (TaggedTrans tag trans) where
107 liftCallCC = Lift.defaultLiftCallCC pack unpack
102 liftCallCC = Lift.defaultLiftCallCC pack unpack
108 liftCallCC' = Lift.defaultLiftCallCC' pack unpack
103 liftCallCC' = Lift.defaultLiftCallCC' pack unpack
109
104
@@ -113,7 +108,7 @@ instance
113 ( Class.MonadCont m
108 ( Class.MonadCont m
114 , Lift.LiftCallCC trans
109 , Lift.LiftCallCC trans
115 , Monad (trans m)
110 , Monad (trans m)
116− ) => Class.MonadCont (TT tag trans m)
111+ ) => Class.MonadCont (TaggedTrans tag trans m)
117 where
112 where
118 callCC = Lift.liftCallCC' Class.callCC
113 callCC = Lift.liftCallCC' Class.callCC
119
114
@@ -121,7 +116,7 @@ instance
121 ( Class.MonadReader r m
116 ( Class.MonadReader r m
122 , Lift.LiftLocal trans
117 , Lift.LiftLocal trans
123 , Monad (trans m)
118 , Monad (trans m)
124− ) => Class.MonadReader r (TT tag trans m)
119+ ) => Class.MonadReader r (TaggedTrans tag trans m)
125 where
120 where
126 ask = lift Class.ask
121 ask = lift Class.ask
127 local = Lift.liftLocal Class.ask Class.local
122 local = Lift.liftLocal Class.ask Class.local
@@ -131,7 +126,7 @@ instance
131 ( Class.MonadState s m
126 ( Class.MonadState s m
132 , MonadTrans trans
127 , MonadTrans trans
133 , Monad (trans m)
128 , Monad (trans m)
134− ) => Class.MonadState s (TT tag trans m)
129+ ) => Class.MonadState s (TaggedTrans tag trans m)
135 where
130 where
136 get = lift Class.get
131 get = lift Class.get
137 put = lift . Class.put
132 put = lift . Class.put
@@ -142,7 +137,7 @@ instance
142 , Lift.LiftListen trans
137 , Lift.LiftListen trans
143 , Lift.LiftPass trans
138 , Lift.LiftPass trans
144 , Monad (trans m)
139 , Monad (trans m)
145− ) => Class.MonadWriter w (TT tag trans m)
140+ ) => Class.MonadWriter w (TaggedTrans tag trans m)
146 where
141 where
147 writer = lift . Class.writer
142 writer = lift . Class.writer
148 tell = lift . Class.tell
143 tell = lift . Class.tell
@@ -153,7 +148,7 @@ instance
153 ( Class.MonadError e m
148 ( Class.MonadError e m
154 , Lift.LiftCatch trans
149 , Lift.LiftCatch trans
155 , Monad (trans m)
150 , Monad (trans m)
156− ) => Class.MonadError e (TT tag trans m)
151+ ) => Class.MonadError e (TaggedTrans tag trans m)
157 where
152 where
158 throwError = lift . Class.throwError
153 throwError = lift . Class.throwError
159 catchError = Lift.liftCatch Class.catchError
154 catchError = Lift.liftCatch Class.catchError
src/Control/Monad/Trans/Ether/Writer.hs+2−2
@@ -34,7 +34,7 @@ import Data.Monoid
34
34
35import Data.Functor.Identity (Identity(..))
35import Data.Functor.Identity (Identity(..))
36import qualified Control.Monad.Trans.Writer.Lazy as Trans
36import qualified Control.Monad.Trans.Writer.Lazy as Trans
37−import Control.Ether.TT
37+import Control.Monad.Trans.Ether.Tagged
38
38
39-- | The parametrizable writer monad.
39-- | The parametrizable writer monad.
40--
40--
@@ -48,7 +48,7 @@ type Writer tag w = WriterT tag w Identity
48--
48--
49-- The 'return' function produces the output 'mempty', while '>>=' combines
49-- The 'return' function produces the output 'mempty', while '>>=' combines
50-- the outputs of the subcomputations using 'mappend'.
50-- the outputs of the subcomputations using 'mappend'.
51−type WriterT tag w = TT tag (Trans.WriterT w)
51+type WriterT tag w = TaggedTrans tag (Trans.WriterT w)
52
52
53-- | Constructor for computations in the writer monad transformer.
53-- | Constructor for computations in the writer monad transformer.
54writerT :: proxy tag -> m (a, w) -> WriterT tag w m a
54writerT :: proxy tag -> m (a, w) -> WriterT tag w m a