on master help sign in
Proper name for TaggedTrans
commit1db55d8a0704223ab7a0921788747cf82c7f5b2b authorIndex Int <vlad.z.4096@gmail.com> dateThu 28 Jan 2016, 11:56 (11 years ago) parent899fa09
8 files changed+40−44
CHANGELOG.md+1 ether.cabal+1−1 src/Control/Monad/Trans/Ether/Except.hs+2−2 src/Control/Monad/Trans/Ether/Reader.hs+2−2 src/Control/Monad/Trans/Ether/State/Lazy.hs+2−2 src/Control/Monad/Trans/Ether/State/Strict.hs+2−2 src/Control/Ether/TT.hs → src/Control/Monad/Trans/Ether/Tagged.hs+28−33 src/Control/Monad/Trans/Ether/Writer.hs+2−2
CHANGELOG.md+1
@@ -4,6 +4,7 @@
44* Poly-kinded tags.
55* Remove `Control.Ether.Tagged`.
66* Replace `Control.Ether.Wrapped` with `Control.Monad.Trans.Ether.Dispatch`.
7+* Unified tagged transformer type in `Control.Monad.Trans.Ether.Tagged`.
78* `MonadThrow`, `MonadCatch`, `MonadMask` instances.
89* Drop `newtype-generics`.
910* Instance search is now more strict.
ether.cabal+1−1
@@ -27,7 +27,6 @@ library
2727 exposed-modules: Control.Ether.Abbr
2828 Control.Ether.Implicit.Abbr
2929 Control.Ether.TH
30− Control.Ether.TT
3130 Control.Monad.Trans.Ether.Reader
3231 Control.Monad.Trans.Ether.Writer
3332 Control.Monad.Trans.Ether.State
@@ -35,6 +34,7 @@ library
3534 Control.Monad.Trans.Ether.State.Strict
3635 Control.Monad.Trans.Ether.Except
3736 Control.Monad.Trans.Ether.Dispatch
37+ Control.Monad.Trans.Ether.Tagged
3838 Control.Monad.Ether
3939 Control.Monad.Ether.Reader
4040 Control.Monad.Ether.Reader.Class
src/Control/Monad/Trans/Ether/Except.hs+2−2
@@ -26,7 +26,7 @@ module Control.Monad.Trans.Ether.Except
2626
2727import Data.Functor.Identity (Identity(..))
2828import qualified Control.Monad.Trans.Except as Trans
29−import Control.Ether.TT
29+import Control.Monad.Trans.Ether.Tagged
3030
3131
3232-- | The parameterizable exception monad.
@@ -45,7 +45,7 @@ runExcept _ = Trans.runExcept . unpack
4545--
4646-- The 'return' function returns a normal value, while '>>=' exits on
4747-- the first exception.
48−type ExceptT tag e = TT tag (Trans.ExceptT e)
48+type ExceptT tag e = TaggedTrans tag (Trans.ExceptT e)
4949
5050-- | Constructor for computations in the exception monad transformer.
5151exceptT :: 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
2626
2727import Data.Functor.Identity (Identity(..))
2828import qualified Control.Monad.Trans.Reader as Trans
29−import Control.Ether.TT
29+import Control.Monad.Trans.Ether.Tagged
3030
3131-- | The parameterizable reader monad.
3232--
@@ -41,7 +41,7 @@ type Reader tag r = ReaderT tag r Identity
4141--
4242-- The 'return' function ignores the environment, while '>>=' passes
4343-- 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)
4545
4646-- | Constructor for computations in the reader monad transformer.
4747readerT :: 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
3030
3131import Data.Functor.Identity (Identity(..))
3232import qualified Control.Monad.Trans.State.Lazy as Trans
33−import Control.Ether.TT
33+import Control.Monad.Trans.Ether.Tagged
3434
3535-- | The parametrizable state monad.
3636--
@@ -44,7 +44,7 @@ type State tag r = StateT tag r Identity
4444--
4545-- The 'return' function leaves the state unchanged, while '>>=' uses
4646-- 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)
4848
4949-- | Constructor for computations in the state monad transformer.
5050stateT :: 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
3030
3131import Data.Functor.Identity (Identity(..))
3232import qualified Control.Monad.Trans.State.Strict as Trans
33−import Control.Ether.TT
33+import Control.Monad.Trans.Ether.Tagged
3434
3535-- | The parametrizable state monad.
3636--
@@ -44,7 +44,7 @@ type State tag r = StateT tag r Identity
4444--
4545-- The 'return' function leaves the state unchanged, while '>>=' uses
4646-- 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)
4848
4949-- | Constructor for computations in the state monad transformer.
5050stateT :: 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 @@
66{-# LANGUAGE UndecidableInstances #-}
77{-# LANGUAGE ConstraintKinds #-}
88{-# LANGUAGE TypeFamilies #-}
9−module Control.Ether.TT where
9+
10+{- |
11+
12+-}
13+
14+module Control.Monad.Trans.Ether.Tagged where
1015
1116import Control.Applicative
1217import Control.Monad (MonadPlus)
@@ -38,44 +43,34 @@ import Data.Coerce (coerce)
3843import Control.Ether.Util (MonadApplicative)
3944
4045-- | 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)
4247 deriving
4348 ( Generic
44− , Functor
45− , Applicative
46− , Alternative
47− , Monad
48− , MonadPlus
49− , MonadFix
50− , MonadTrans
51− , MonadIO
52− , MFunctor
53− , MMonad
54− , MonadThrow
55− , MonadCatch
56− , MonadMask )
49+ , Functor, Applicative, Alternative, Monad, MonadPlus
50+ , MonadFix, MonadTrans, MonadIO, MFunctor, MMonad
51+ , MonadThrow, MonadCatch, MonadMask )
5752
5853-- | Type-restricted 'coerce'.
59−pack :: trans m a -> TT tag trans m a
54+pack :: trans m a -> TaggedTrans tag trans m a
6055pack = coerce
6156
6257-- | Type-restricted 'coerce'.
63−unpack :: TT tag trans m a -> trans m a
58+unpack :: TaggedTrans tag trans m a -> trans m a
6459unpack = coerce
6560
6661instance
6762 ( MB.MonadBase b m
6863 , MonadTrans trans
6964 , MonadApplicative (trans m)
70− ) => MB.MonadBase b (TT tag trans m)
65+ ) => MB.MonadBase b (TaggedTrans tag trans m)
7166 where
7267 liftBase = MB.liftBaseDefault
7368
7469instance
7570 ( MC.MonadTransControl trans
76− ) => MC.MonadTransControl (TT tag trans)
71+ ) => MC.MonadTransControl (TaggedTrans tag trans)
7772 where
78− type StT (TT tag trans) a = MC.StT trans a
73+ type StT (TaggedTrans tag trans) a = MC.StT trans a
7974 liftWith = MC.defaultLiftWith pack unpack
8075 restoreT = MC.defaultRestoreT pack
8176
@@ -83,27 +78,27 @@ instance
8378 ( MC.MonadBaseControl b m
8479 , MC.MonadTransControl trans
8580 , MonadApplicative (trans m)
86− ) => MC.MonadBaseControl b (TT tag trans m)
81+ ) => MC.MonadBaseControl b (TaggedTrans tag trans m)
8782 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
8984 liftBaseWith = MC.defaultLiftBaseWith
9085 restoreM = MC.defaultRestoreM
9186
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
9388
94−instance Lift.LiftLocal trans => Lift.LiftLocal (TT tag trans) where
89+instance Lift.LiftLocal trans => Lift.LiftLocal (TaggedTrans tag trans) where
9590 liftLocal = Lift.defaultLiftLocal pack unpack
9691
97−instance Lift.LiftCatch trans => Lift.LiftCatch (TT tag trans) where
92+instance Lift.LiftCatch trans => Lift.LiftCatch (TaggedTrans tag trans) where
9893 liftCatch = Lift.defaultLiftCatch pack unpack
9994
100−instance Lift.LiftListen trans => Lift.LiftListen (TT tag trans) where
95+instance Lift.LiftListen trans => Lift.LiftListen (TaggedTrans tag trans) where
10196 liftListen = Lift.defaultLiftListen pack unpack
10297
103−instance Lift.LiftPass trans => Lift.LiftPass (TT tag trans) where
98+instance Lift.LiftPass trans => Lift.LiftPass (TaggedTrans tag trans) where
10499 liftPass = Lift.defaultLiftPass pack unpack
105100
106−instance Lift.LiftCallCC trans => Lift.LiftCallCC (TT tag trans) where
101+instance Lift.LiftCallCC trans => Lift.LiftCallCC (TaggedTrans tag trans) where
107102 liftCallCC = Lift.defaultLiftCallCC pack unpack
108103 liftCallCC' = Lift.defaultLiftCallCC' pack unpack
109104
@@ -113,7 +108,7 @@ instance
113108 ( Class.MonadCont m
114109 , Lift.LiftCallCC trans
115110 , Monad (trans m)
116− ) => Class.MonadCont (TT tag trans m)
111+ ) => Class.MonadCont (TaggedTrans tag trans m)
117112 where
118113 callCC = Lift.liftCallCC' Class.callCC
119114
@@ -121,7 +116,7 @@ instance
121116 ( Class.MonadReader r m
122117 , Lift.LiftLocal trans
123118 , Monad (trans m)
124− ) => Class.MonadReader r (TT tag trans m)
119+ ) => Class.MonadReader r (TaggedTrans tag trans m)
125120 where
126121 ask = lift Class.ask
127122 local = Lift.liftLocal Class.ask Class.local
@@ -131,7 +126,7 @@ instance
131126 ( Class.MonadState s m
132127 , MonadTrans trans
133128 , Monad (trans m)
134− ) => Class.MonadState s (TT tag trans m)
129+ ) => Class.MonadState s (TaggedTrans tag trans m)
135130 where
136131 get = lift Class.get
137132 put = lift . Class.put
@@ -142,7 +137,7 @@ instance
142137 , Lift.LiftListen trans
143138 , Lift.LiftPass trans
144139 , Monad (trans m)
145− ) => Class.MonadWriter w (TT tag trans m)
140+ ) => Class.MonadWriter w (TaggedTrans tag trans m)
146141 where
147142 writer = lift . Class.writer
148143 tell = lift . Class.tell
@@ -153,7 +148,7 @@ instance
153148 ( Class.MonadError e m
154149 , Lift.LiftCatch trans
155150 , Monad (trans m)
156− ) => Class.MonadError e (TT tag trans m)
151+ ) => Class.MonadError e (TaggedTrans tag trans m)
157152 where
158153 throwError = lift . Class.throwError
159154 catchError = Lift.liftCatch Class.catchError
src/Control/Monad/Trans/Ether/Writer.hs+2−2
@@ -34,7 +34,7 @@ import Data.Monoid
3434
3535import Data.Functor.Identity (Identity(..))
3636import qualified Control.Monad.Trans.Writer.Lazy as Trans
37−import Control.Ether.TT
37+import Control.Monad.Trans.Ether.Tagged
3838
3939-- | The parametrizable writer monad.
4040--
@@ -48,7 +48,7 @@ type Writer tag w = WriterT tag w Identity
4848--
4949-- The 'return' function produces the output 'mempty', while '>>=' combines
5050-- 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)
5252
5353-- | Constructor for computations in the writer monad transformer.
5454writerT :: proxy tag -> m (a, w) -> WriterT tag w m a