on master help sign in
MonadBase and MonadBaseControl instances
7b21efcIndex Int
ether.cabal+2−1
@@ -58,10 +58,11 @@ library
58
58
59 build-depends: base >=4.7 && <4.9
59 build-depends: base >=4.7 && <4.9
60 , transformers >=0.4.2
60 , transformers >=0.4.2
61− , transformers-lift >=0.0
61+ , transformers-lift >=0.1
62 , mtl >=2.2.1
62 , mtl >=2.2.1
63 , mmorph >=1.0.4
63 , mmorph >=1.0.4
64 , monad-control >=1.0.0.4
64 , monad-control >=1.0.0.4
65+ , transformers-base >=0.4.4
65 , template-haskell >=2.9
66 , template-haskell >=2.9
66 , newtype-generics >=0.4.1
67 , newtype-generics >=0.4.1
67
68
src/Control/Monad/Trans/Ether/Except.hs+9
@@ -34,6 +34,7 @@ import Control.Ether.Tagged (Taggable(..), Tagged(..))
34import GHC.Generics (Generic)
34import GHC.Generics (Generic)
35import qualified Control.Newtype as NT
35import qualified Control.Newtype as NT
36
36
37+import qualified Control.Monad.Base as MB
37import qualified Control.Monad.Trans.Control as MC
38import qualified Control.Monad.Trans.Control as MC
38import qualified Control.Monad.Trans.Except as Trans
39import qualified Control.Monad.Trans.Except as Trans
39
40
@@ -74,11 +75,19 @@ newtype ExceptT tag e m a = ExceptT (Trans.ExceptT e m a)
74
75
75instance NT.Newtype (ExceptT tag e m a)
76instance NT.Newtype (ExceptT tag e m a)
76
77
78+instance MB.MonadBase b m => MB.MonadBase b (ExceptT tag e m) where
79+ liftBase = MB.liftBaseDefault
80+
77instance MC.MonadTransControl (ExceptT tag e) where
81instance MC.MonadTransControl (ExceptT tag e) where
78 type StT (ExceptT tag e) a = MC.StT (Trans.ExceptT e) a
82 type StT (ExceptT tag e) a = MC.StT (Trans.ExceptT e) a
79 liftWith = MC.defaultLiftWith NT.pack NT.unpack
83 liftWith = MC.defaultLiftWith NT.pack NT.unpack
80 restoreT = MC.defaultRestoreT NT.pack
84 restoreT = MC.defaultRestoreT NT.pack
81
85
86+instance MC.MonadBaseControl b m => MC.MonadBaseControl b (ExceptT tag e m) where
87+ type StM (ExceptT tag e m) a = MC.ComposeSt (ExceptT tag e) m a
88+ liftBaseWith = MC.defaultLiftBaseWith
89+ restoreM = MC.defaultRestoreM
90+
82type instance Lift.StT (ExceptT tag e) a = MC.StT (ExceptT tag e) a
91type instance Lift.StT (ExceptT tag e) a = MC.StT (ExceptT tag e) a
83
92
84instance Lift.LiftLocal (ExceptT tag e) where
93instance Lift.LiftLocal (ExceptT tag e) where
src/Control/Monad/Trans/Ether/Reader.hs+9
@@ -34,6 +34,7 @@ import Control.Ether.Tagged (Taggable(..), Tagged(..))
34import GHC.Generics (Generic)
34import GHC.Generics (Generic)
35import qualified Control.Newtype as NT
35import qualified Control.Newtype as NT
36
36
37+import qualified Control.Monad.Base as MB
37import qualified Control.Monad.Trans.Control as MC
38import qualified Control.Monad.Trans.Control as MC
38import qualified Control.Monad.Trans.Reader as Trans
39import qualified Control.Monad.Trans.Reader as Trans
39
40
@@ -70,11 +71,19 @@ newtype ReaderT tag r m a = ReaderT (Trans.ReaderT r m a)
70
71
71instance NT.Newtype (ReaderT tag r m a)
72instance NT.Newtype (ReaderT tag r m a)
72
73
74+instance MB.MonadBase b m => MB.MonadBase b (ReaderT tag r m) where
75+ liftBase = MB.liftBaseDefault
76+
73instance MC.MonadTransControl (ReaderT tag r) where
77instance MC.MonadTransControl (ReaderT tag r) where
74 type StT (ReaderT tag r) a = MC.StT (Trans.ReaderT r) a
78 type StT (ReaderT tag r) a = MC.StT (Trans.ReaderT r) a
75 liftWith = MC.defaultLiftWith NT.pack NT.unpack
79 liftWith = MC.defaultLiftWith NT.pack NT.unpack
76 restoreT = MC.defaultRestoreT NT.pack
80 restoreT = MC.defaultRestoreT NT.pack
77
81
82+instance MC.MonadBaseControl b m => MC.MonadBaseControl b (ReaderT tag r m) where
83+ type StM (ReaderT tag r m) a = MC.ComposeSt (ReaderT tag r) m a
84+ liftBaseWith = MC.defaultLiftBaseWith
85+ restoreM = MC.defaultRestoreM
86+
78type instance Lift.StT (ReaderT tag r) a = MC.StT (ReaderT tag r) a
87type instance Lift.StT (ReaderT tag r) a = MC.StT (ReaderT tag r) a
79
88
80instance Lift.LiftLocal (ReaderT tag r) where
89instance Lift.LiftLocal (ReaderT tag r) where
src/Control/Monad/Trans/Ether/State/Lazy.hs+9
@@ -38,6 +38,7 @@ import Control.Ether.Tagged (Taggable(..), Tagged(..))
38import GHC.Generics (Generic)
38import GHC.Generics (Generic)
39import qualified Control.Newtype as NT
39import qualified Control.Newtype as NT
40
40
41+import qualified Control.Monad.Base as MB
41import qualified Control.Monad.Trans.Control as MC
42import qualified Control.Monad.Trans.Control as MC
42import qualified Control.Monad.Trans.State.Lazy as Trans
43import qualified Control.Monad.Trans.State.Lazy as Trans
43
44
@@ -74,11 +75,19 @@ newtype StateT tag s m a = StateT (Trans.StateT s m a)
74
75
75instance NT.Newtype (StateT tag s m a)
76instance NT.Newtype (StateT tag s m a)
76
77
78+instance MB.MonadBase b m => MB.MonadBase b (StateT tag s m) where
79+ liftBase = MB.liftBaseDefault
80+
77instance MC.MonadTransControl (StateT tag s) where
81instance MC.MonadTransControl (StateT tag s) where
78 type StT (StateT tag s) a = MC.StT (Trans.StateT s) a
82 type StT (StateT tag s) a = MC.StT (Trans.StateT s) a
79 liftWith = MC.defaultLiftWith NT.pack NT.unpack
83 liftWith = MC.defaultLiftWith NT.pack NT.unpack
80 restoreT = MC.defaultRestoreT NT.pack
84 restoreT = MC.defaultRestoreT NT.pack
81
85
86+instance MC.MonadBaseControl b m => MC.MonadBaseControl b (StateT tag s m) where
87+ type StM (StateT tag s m) a = MC.ComposeSt (StateT tag s) m a
88+ liftBaseWith = MC.defaultLiftBaseWith
89+ restoreM = MC.defaultRestoreM
90+
82type instance Lift.StT (StateT tag s) a = MC.StT (StateT tag s) a
91type instance Lift.StT (StateT tag s) a = MC.StT (StateT tag s) a
83
92
84instance Lift.LiftLocal (StateT tag s) where
93instance Lift.LiftLocal (StateT tag s) where
src/Control/Monad/Trans/Ether/State/Strict.hs+9
@@ -38,6 +38,7 @@ import Control.Ether.Tagged (Taggable(..), Tagged(..))
38import GHC.Generics (Generic)
38import GHC.Generics (Generic)
39import qualified Control.Newtype as NT
39import qualified Control.Newtype as NT
40
40
41+import qualified Control.Monad.Base as MB
41import qualified Control.Monad.Trans.Control as MC
42import qualified Control.Monad.Trans.Control as MC
42import qualified Control.Monad.Trans.State.Strict as Trans
43import qualified Control.Monad.Trans.State.Strict as Trans
43
44
@@ -74,11 +75,19 @@ newtype StateT tag s m a = StateT (Trans.StateT s m a)
74
75
75instance NT.Newtype (StateT tag s m a)
76instance NT.Newtype (StateT tag s m a)
76
77
78+instance MB.MonadBase b m => MB.MonadBase b (StateT tag s m) where
79+ liftBase = MB.liftBaseDefault
80+
77instance MC.MonadTransControl (StateT tag s) where
81instance MC.MonadTransControl (StateT tag s) where
78 type StT (StateT tag s) a = MC.StT (Trans.StateT s) a
82 type StT (StateT tag s) a = MC.StT (Trans.StateT s) a
79 liftWith = MC.defaultLiftWith NT.pack NT.unpack
83 liftWith = MC.defaultLiftWith NT.pack NT.unpack
80 restoreT = MC.defaultRestoreT NT.pack
84 restoreT = MC.defaultRestoreT NT.pack
81
85
86+instance MC.MonadBaseControl b m => MC.MonadBaseControl b (StateT tag s m) where
87+ type StM (StateT tag s m) a = MC.ComposeSt (StateT tag s) m a
88+ liftBaseWith = MC.defaultLiftBaseWith
89+ restoreM = MC.defaultRestoreM
90+
82type instance Lift.StT (StateT tag s) a = MC.StT (StateT tag s) a
91type instance Lift.StT (StateT tag s) a = MC.StT (StateT tag s) a
83
92
84instance Lift.LiftLocal (StateT tag s) where
93instance Lift.LiftLocal (StateT tag s) where
src/Control/Monad/Trans/Ether/Writer.hs+11−2
@@ -42,6 +42,7 @@ import Control.Ether.Tagged (Taggable(..), Tagged(..))
42import GHC.Generics (Generic)
42import GHC.Generics (Generic)
43import qualified Control.Newtype as NT
43import qualified Control.Newtype as NT
44
44
45+import qualified Control.Monad.Base as MB
45import qualified Control.Monad.Trans.Control as MC
46import qualified Control.Monad.Trans.Control as MC
46import qualified Control.Monad.Trans.Writer.Lazy as Trans
47import qualified Control.Monad.Trans.Writer.Lazy as Trans
47
48
@@ -77,11 +78,19 @@ newtype WriterT tag w m a = WriterT (Trans.WriterT w m a)
77
78
78instance NT.Newtype (WriterT tag w m a)
79instance NT.Newtype (WriterT tag w m a)
79
80
81+instance (Monoid w, MB.MonadBase b m) => MB.MonadBase b (WriterT tag w m) where
82+ liftBase = MB.liftBaseDefault
83+
80instance Monoid w => MC.MonadTransControl (WriterT tag w) where
84instance Monoid w => MC.MonadTransControl (WriterT tag w) where
81 type StT (WriterT tag w) a = MC.StT (Trans.WriterT w) a
85 type StT (WriterT tag w) a = MC.StT (Trans.WriterT w) a
82 liftWith = MC.defaultLiftWith NT.pack NT.unpack
86 liftWith = MC.defaultLiftWith NT.pack NT.unpack
83 restoreT = MC.defaultRestoreT NT.pack
87 restoreT = MC.defaultRestoreT NT.pack
84
88
89+instance (Monoid w, MC.MonadBaseControl b m) => MC.MonadBaseControl b (WriterT tag w m) where
90+ type StM (WriterT tag w m) a = MC.ComposeSt (WriterT tag w) m a
91+ liftBaseWith = MC.defaultLiftBaseWith
92+ restoreM = MC.defaultRestoreM
93+
85type instance Lift.StT (WriterT tag w) a = MC.StT (WriterT tag w) a
94type instance Lift.StT (WriterT tag w) a = MC.StT (WriterT tag w) a
86
95
87instance Monoid w => Lift.LiftLocal (WriterT tag w) where
96instance Monoid w => Lift.LiftLocal (WriterT tag w) where
@@ -97,8 +106,8 @@ instance Monoid w' => Lift.LiftPass (WriterT tag w') where
97 liftPass = Lift.defaultLiftPass NT.pack NT.unpack
106 liftPass = Lift.defaultLiftPass NT.pack NT.unpack
98
107
99instance Monoid w => Lift.LiftCallCC (WriterT tag w) where
108instance Monoid w => Lift.LiftCallCC (WriterT tag w) where
100− liftCallCC = Lift.defaultLiftCallCC WT runWT
109+ liftCallCC = Lift.defaultLiftCallCC NT.pack NT.unpack
101− liftCallCC' = Lift.defaultLiftCallCC WT runWT
110+ liftCallCC' = Lift.defaultLiftCallCC NT.pack NT.unpack
102
111
103instance Taggable (WriterT tag w m) where
112instance Taggable (WriterT tag w m) where
104 type Tag (WriterT tag w m) = 'Just tag
113 type Tag (WriterT tag w m) = 'Just tag