git.iko.soy/typeable/transformers-lift
on master help sign in
INLINE annotations + support for CPS.WriterT, SelectT, AccumT (#4)
54641adVladislav Zavialov
.travis.yml+4−2
@@ -4,7 +4,8 @@ env:
4 - CABALVER=1.18 GHCVER=7.6.3
4 - CABALVER=1.18 GHCVER=7.6.3
5 - CABALVER=1.18 GHCVER=7.8.4
5 - CABALVER=1.18 GHCVER=7.8.4
6 - CABALVER=1.22 GHCVER=7.10.3
6 - CABALVER=1.22 GHCVER=7.10.3
7− - CABALVER=1.24 GHCVER=8.0.1
7+ - CABALVER=1.24 GHCVER=8.0.2
8+ - CABALVER=1.24 GHCVER=8.2.1
8 - CABALVER=head GHCVER=head
9 - CABALVER=head GHCVER=head
9
10
10before_install:
11before_install:
@@ -27,7 +28,8 @@ addons:
27 - ghc-7.6.3
28 - ghc-7.6.3
28 - ghc-7.8.4
29 - ghc-7.8.4
29 - ghc-7.10.3
30 - ghc-7.10.3
30− - ghc-8.0.1
31+ - ghc-8.0.2
32+ - ghc-8.2.1
31 - ghc-head
33 - ghc-head
32 - cabal-install-1.18
34 - cabal-install-1.18
33 - cabal-install-1.22
35 - cabal-install-1.22
src/Control/Monad/Trans/Lift/CallCC.hs+31
@@ -23,10 +23,13 @@ import qualified Control.Monad.Trans.Maybe as M
23import qualified Control.Monad.Trans.Reader as R
23import qualified Control.Monad.Trans.Reader as R
24import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
24import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
25import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
25import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
26+import qualified Control.Monad.Trans.RWS.CPS as RWS.CPS
26import qualified Control.Monad.Trans.State.Lazy as S.Lazy
27import qualified Control.Monad.Trans.State.Lazy as S.Lazy
27import qualified Control.Monad.Trans.State.Strict as S.Strict
28import qualified Control.Monad.Trans.State.Strict as S.Strict
28import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
29import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
29import qualified Control.Monad.Trans.Writer.Strict as W.Strict
30import qualified Control.Monad.Trans.Writer.Strict as W.Strict
31+import qualified Control.Monad.Trans.Writer.CPS as W.CPS
32+import qualified Control.Monad.Trans.Accum as Acc
30
33
31import Control.Monad.Trans.Lift.StT
34import Control.Monad.Trans.Lift.StT
32
35
@@ -73,38 +76,66 @@ defaultLiftCallCC' t unT callCC f
73
76
74instance LiftCallCC (E.ExceptT e) where
77instance LiftCallCC (E.ExceptT e) where
75 liftCallCC = E.liftCallCC
78 liftCallCC = E.liftCallCC
79+ {-# INLINE liftCallCC #-}
76
80
77instance LiftCallCC I.IdentityT where
81instance LiftCallCC I.IdentityT where
78 liftCallCC = I.liftCallCC
82 liftCallCC = I.liftCallCC
83+ {-# INLINE liftCallCC #-}
79
84
80instance LiftCallCC L.ListT where
85instance LiftCallCC L.ListT where
81 liftCallCC = L.liftCallCC
86 liftCallCC = L.liftCallCC
87+ {-# INLINE liftCallCC #-}
82
88
83instance LiftCallCC M.MaybeT where
89instance LiftCallCC M.MaybeT where
84 liftCallCC = M.liftCallCC
90 liftCallCC = M.liftCallCC
91+ {-# INLINE liftCallCC #-}
85
92
86instance LiftCallCC (R.ReaderT r) where
93instance LiftCallCC (R.ReaderT r) where
87 liftCallCC = R.liftCallCC
94 liftCallCC = R.liftCallCC
95+ {-# INLINE liftCallCC #-}
88
96
89instance Monoid w => LiftCallCC (W.Lazy.WriterT w) where
97instance Monoid w => LiftCallCC (W.Lazy.WriterT w) where
90 liftCallCC = W.Lazy.liftCallCC
98 liftCallCC = W.Lazy.liftCallCC
99+ {-# INLINE liftCallCC #-}
91
100
92instance Monoid w => LiftCallCC (W.Strict.WriterT w) where
101instance Monoid w => LiftCallCC (W.Strict.WriterT w) where
93 liftCallCC = W.Strict.liftCallCC
102 liftCallCC = W.Strict.liftCallCC
103+ {-# INLINE liftCallCC #-}
104+
105+instance Monoid w => LiftCallCC (W.CPS.WriterT w) where
106+ liftCallCC = W.CPS.liftCallCC
107+ {-# INLINE liftCallCC #-}
94
108
95instance Monoid w => LiftCallCC (RWS.Lazy.RWST r w s) where
109instance Monoid w => LiftCallCC (RWS.Lazy.RWST r w s) where
96 liftCallCC = RWS.Lazy.liftCallCC
110 liftCallCC = RWS.Lazy.liftCallCC
111+ {-# INLINE liftCallCC #-}
97 liftCallCC' = RWS.Lazy.liftCallCC'
112 liftCallCC' = RWS.Lazy.liftCallCC'
113+ {-# INLINE liftCallCC' #-}
98
114
99instance Monoid w => LiftCallCC (RWS.Strict.RWST r w s) where
115instance Monoid w => LiftCallCC (RWS.Strict.RWST r w s) where
100 liftCallCC = RWS.Strict.liftCallCC
116 liftCallCC = RWS.Strict.liftCallCC
117+ {-# INLINE liftCallCC #-}
101 liftCallCC' = RWS.Strict.liftCallCC'
118 liftCallCC' = RWS.Strict.liftCallCC'
119+ {-# INLINE liftCallCC' #-}
120+
121+instance Monoid w => LiftCallCC (RWS.CPS.RWST r w s) where
122+ liftCallCC = RWS.CPS.liftCallCC
123+ {-# INLINE liftCallCC #-}
124+ liftCallCC' = RWS.CPS.liftCallCC'
125+ {-# INLINE liftCallCC' #-}
102
126
103instance LiftCallCC (S.Lazy.StateT s) where
127instance LiftCallCC (S.Lazy.StateT s) where
104 liftCallCC = S.Lazy.liftCallCC
128 liftCallCC = S.Lazy.liftCallCC
129+ {-# INLINE liftCallCC #-}
105 liftCallCC' = S.Lazy.liftCallCC'
130 liftCallCC' = S.Lazy.liftCallCC'
131+ {-# INLINE liftCallCC' #-}
106
132
107instance LiftCallCC (S.Strict.StateT s) where
133instance LiftCallCC (S.Strict.StateT s) where
108 liftCallCC = S.Strict.liftCallCC
134 liftCallCC = S.Strict.liftCallCC
135+ {-# INLINE liftCallCC #-}
109 liftCallCC' = S.Strict.liftCallCC'
136 liftCallCC' = S.Strict.liftCallCC'
137+ {-# INLINE liftCallCC' #-}
110
138
139+instance Monoid w => LiftCallCC (Acc.AccumT w) where
140+ liftCallCC = Acc.liftCallCC
141+ {-# INLINE liftCallCC #-}
src/Control/Monad/Trans/Lift/Catch.hs+26
@@ -22,10 +22,13 @@ import qualified Control.Monad.Trans.Maybe as M
22import qualified Control.Monad.Trans.Reader as R
22import qualified Control.Monad.Trans.Reader as R
23import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
23import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
24import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
24import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
25+import qualified Control.Monad.Trans.RWS.CPS as RWS.CPS
25import qualified Control.Monad.Trans.State.Lazy as S.Lazy
26import qualified Control.Monad.Trans.State.Lazy as S.Lazy
26import qualified Control.Monad.Trans.State.Strict as S.Strict
27import qualified Control.Monad.Trans.State.Strict as S.Strict
27import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
28import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
28import qualified Control.Monad.Trans.Writer.Strict as W.Strict
29import qualified Control.Monad.Trans.Writer.Strict as W.Strict
30+import qualified Control.Monad.Trans.Writer.CPS as W.CPS
31+import qualified Control.Monad.Trans.Accum as Acc
29
32
30import Control.Monad.Trans.Lift.StT
33import Control.Monad.Trans.Lift.StT
31
34
@@ -50,33 +53,56 @@ defaultLiftCatch t unT f m h = t $ liftCatch f (unT m) (unT . h)
50
53
51instance LiftCatch (E.ExceptT e) where
54instance LiftCatch (E.ExceptT e) where
52 liftCatch f m h = E.ExceptT $ f (E.runExceptT m) (E.runExceptT . h)
55 liftCatch f m h = E.ExceptT $ f (E.runExceptT m) (E.runExceptT . h)
56+ {-# INLINE liftCatch #-}
53
57
54instance LiftCatch I.IdentityT where
58instance LiftCatch I.IdentityT where
55 liftCatch = I.liftCatch
59 liftCatch = I.liftCatch
60+ {-# INLINE liftCatch #-}
56
61
57instance LiftCatch L.ListT where
62instance LiftCatch L.ListT where
58 liftCatch = L.liftCatch
63 liftCatch = L.liftCatch
64+ {-# INLINE liftCatch #-}
59
65
60instance LiftCatch M.MaybeT where
66instance LiftCatch M.MaybeT where
61 liftCatch = M.liftCatch
67 liftCatch = M.liftCatch
68+ {-# INLINE liftCatch #-}
62
69
63instance LiftCatch (R.ReaderT r) where
70instance LiftCatch (R.ReaderT r) where
64 liftCatch = R.liftCatch
71 liftCatch = R.liftCatch
72+ {-# INLINE liftCatch #-}
65
73
66instance Monoid w => LiftCatch (RWS.Lazy.RWST r w s) where
74instance Monoid w => LiftCatch (RWS.Lazy.RWST r w s) where
67 liftCatch = RWS.Lazy.liftCatch
75 liftCatch = RWS.Lazy.liftCatch
76+ {-# INLINE liftCatch #-}
68
77
69instance Monoid w => LiftCatch (RWS.Strict.RWST r w s) where
78instance Monoid w => LiftCatch (RWS.Strict.RWST r w s) where
70 liftCatch = RWS.Strict.liftCatch
79 liftCatch = RWS.Strict.liftCatch
80+ {-# INLINE liftCatch #-}
81+
82+instance Monoid w => LiftCatch (RWS.CPS.RWST r w s) where
83+ liftCatch = RWS.CPS.liftCatch
84+ {-# INLINE liftCatch #-}
71
85
72instance LiftCatch (S.Lazy.StateT s) where
86instance LiftCatch (S.Lazy.StateT s) where
73 liftCatch = S.Lazy.liftCatch
87 liftCatch = S.Lazy.liftCatch
88+ {-# INLINE liftCatch #-}
74
89
75instance LiftCatch (S.Strict.StateT s) where
90instance LiftCatch (S.Strict.StateT s) where
76 liftCatch = S.Strict.liftCatch
91 liftCatch = S.Strict.liftCatch
92+ {-# INLINE liftCatch #-}
77
93
78instance Monoid w => LiftCatch (W.Lazy.WriterT w) where
94instance Monoid w => LiftCatch (W.Lazy.WriterT w) where
79 liftCatch = W.Lazy.liftCatch
95 liftCatch = W.Lazy.liftCatch
96+ {-# INLINE liftCatch #-}
80
97
81instance Monoid w => LiftCatch (W.Strict.WriterT w) where
98instance Monoid w => LiftCatch (W.Strict.WriterT w) where
82 liftCatch = W.Strict.liftCatch
99 liftCatch = W.Strict.liftCatch
100+ {-# INLINE liftCatch #-}
101+
102+instance Monoid w => LiftCatch (W.CPS.WriterT w) where
103+ liftCatch = W.CPS.liftCatch
104+ {-# INLINE liftCatch #-}
105+
106+instance Monoid w => LiftCatch (Acc.AccumT w) where
107+ liftCatch = Acc.liftCatch
108+ {-# INLINE liftCatch #-}
src/Control/Monad/Trans/Lift/Listen.hs+39−10
@@ -15,16 +15,19 @@ import Data.Monoid
15import Control.Monad.Signatures
15import Control.Monad.Signatures
16import Control.Monad.Trans.Class
16import Control.Monad.Trans.Class
17
17
18−import qualified Control.Monad.Trans.Except as E
18+import qualified Control.Monad.Trans.Except as E
19−import qualified Control.Monad.Trans.Identity as I
19+import qualified Control.Monad.Trans.Identity as I
20−import qualified Control.Monad.Trans.Maybe as M
20+import qualified Control.Monad.Trans.Maybe as M
21−import qualified Control.Monad.Trans.Reader as R
21+import qualified Control.Monad.Trans.Reader as R
22−import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
22+import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
23−import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
23+import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
24+import qualified Control.Monad.Trans.RWS.CPS.Internal as RWS.CPS
24−import qualified Control.Monad.Trans.State.Lazy as S.Lazy
25+import qualified Control.Monad.Trans.State.Lazy as S.Lazy
25−import qualified Control.Monad.Trans.State.Strict as S.Strict
26+import qualified Control.Monad.Trans.State.Strict as S.Strict
26−import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
27+import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
27−import qualified Control.Monad.Trans.Writer.Strict as W.Strict
28+import qualified Control.Monad.Trans.Writer.Strict as W.Strict
29+import qualified Control.Monad.Trans.Writer.CPS.Internal as W.CPS
30+import qualified Control.Monad.Trans.Accum as Acc
28
31
29import Control.Monad.Trans.Lift.StT
32import Control.Monad.Trans.Lift.StT
30
33
@@ -49,38 +52,64 @@ defaultLiftListen t unT listen m = t $ liftListen listen (unT m)
49
52
50instance LiftListen (E.ExceptT e) where
53instance LiftListen (E.ExceptT e) where
51 liftListen = E.liftListen
54 liftListen = E.liftListen
55+ {-# INLINE liftListen #-}
52
56
53instance LiftListen I.IdentityT where
57instance LiftListen I.IdentityT where
54 liftListen = I.mapIdentityT
58 liftListen = I.mapIdentityT
59+ {-# INLINE liftListen #-}
55
60
56instance LiftListen M.MaybeT where
61instance LiftListen M.MaybeT where
57 liftListen = M.liftListen
62 liftListen = M.liftListen
63+ {-# INLINE liftListen #-}
58
64
59instance LiftListen (R.ReaderT r) where
65instance LiftListen (R.ReaderT r) where
60 liftListen = R.mapReaderT
66 liftListen = R.mapReaderT
67+ {-# INLINE liftListen #-}
61
68
62instance LiftListen (S.Lazy.StateT s) where
69instance LiftListen (S.Lazy.StateT s) where
63 liftListen = S.Lazy.liftListen
70 liftListen = S.Lazy.liftListen
71+ {-# INLINE liftListen #-}
64
72
65instance LiftListen (S.Strict.StateT s) where
73instance LiftListen (S.Strict.StateT s) where
66 liftListen = S.Strict.liftListen
74 liftListen = S.Strict.liftListen
75+ {-# INLINE liftListen #-}
67
76
68instance Monoid w' => LiftListen (RWS.Lazy.RWST r w' s) where
77instance Monoid w' => LiftListen (RWS.Lazy.RWST r w' s) where
69 liftListen listen m = RWS.Lazy.RWST $ \r s -> do
78 liftListen listen m = RWS.Lazy.RWST $ \r s -> do
70 ~((a, w', s'), w) <- listen (RWS.Lazy.runRWST m r s)
79 ~((a, w', s'), w) <- listen (RWS.Lazy.runRWST m r s)
71 return ((a, w), w', s')
80 return ((a, w), w', s')
81+ {-# INLINE liftListen #-}
72
82
73instance Monoid w' => LiftListen (RWS.Strict.RWST r w' s) where
83instance Monoid w' => LiftListen (RWS.Strict.RWST r w' s) where
74 liftListen listen m = RWS.Strict.RWST $ \r s -> do
84 liftListen listen m = RWS.Strict.RWST $ \r s -> do
75 ((a, w', s'), w) <- listen (RWS.Strict.runRWST m r s)
85 ((a, w', s'), w) <- listen (RWS.Strict.runRWST m r s)
76 return ((a, w), w', s')
86 return ((a, w), w', s')
87+ {-# INLINE liftListen #-}
88+
89+instance Monoid w' => LiftListen (RWS.CPS.RWST r w' s) where
90+ liftListen listen m = RWS.CPS.RWST $ \r w_ s -> do
91+ ((a, w', s'), w) <- listen (RWS.CPS.unRWST m r w_ s)
92+ return ((a, w), w', s')
93+ {-# INLINE liftListen #-}
77
94
78instance Monoid w' => LiftListen (W.Lazy.WriterT w') where
95instance Monoid w' => LiftListen (W.Lazy.WriterT w') where
79 liftListen listen m = W.Lazy.WriterT $ do
96 liftListen listen m = W.Lazy.WriterT $ do
80 ~((a, w'), w) <- listen (W.Lazy.runWriterT m)
97 ~((a, w'), w) <- listen (W.Lazy.runWriterT m)
81 return ((a, w), w')
98 return ((a, w), w')
99+ {-# INLINE liftListen #-}
82
100
83instance Monoid w' => LiftListen (W.Strict.WriterT w') where
101instance Monoid w' => LiftListen (W.Strict.WriterT w') where
84 liftListen listen m = W.Strict.WriterT $ do
102 liftListen listen m = W.Strict.WriterT $ do
85 ((a, w'), w) <- listen (W.Strict.runWriterT m)
103 ((a, w'), w) <- listen (W.Strict.runWriterT m)
86 return ((a, w), w')
104 return ((a, w), w')
105+ {-# INLINE liftListen #-}
106+
107+instance Monoid w' => LiftListen (W.CPS.WriterT w') where
108+ liftListen listen m = W.CPS.WriterT $ \w_ -> do
109+ ((a, w'), w) <- listen (W.CPS.unWriterT m w_)
110+ return ((a, w), w')
111+ {-# INLINE liftListen #-}
112+
113+instance Monoid w' => LiftListen (Acc.AccumT w') where
114+ liftListen = Acc.liftListen
115+ {-# INLINE liftListen #-}
src/Control/Monad/Trans/Lift/Local.hs+27
@@ -22,10 +22,13 @@ import qualified Control.Monad.Trans.Maybe as M
22import qualified Control.Monad.Trans.Reader as R
22import qualified Control.Monad.Trans.Reader as R
23import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
23import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
24import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
24import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
25+import qualified Control.Monad.Trans.RWS.CPS as RWS.CPS
25import qualified Control.Monad.Trans.State.Lazy as S.Lazy
26import qualified Control.Monad.Trans.State.Lazy as S.Lazy
26import qualified Control.Monad.Trans.State.Strict as S.Strict
27import qualified Control.Monad.Trans.State.Strict as S.Strict
27import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
28import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
28import qualified Control.Monad.Trans.Writer.Strict as W.Strict
29import qualified Control.Monad.Trans.Writer.Strict as W.Strict
30+import qualified Control.Monad.Trans.Writer.CPS as W.CPS
31+import qualified Control.Monad.Trans.Accum as Acc
29
32
30-- | Signature of the @local@ operation,
33-- | Signature of the @local@ operation,
31-- introduced in "Control.Monad.Trans.Reader".
34-- introduced in "Control.Monad.Trans.Reader".
@@ -51,36 +54,60 @@ defaultLiftLocal t unT a l f = t . liftLocal a l f . unT
51
54
52instance LiftLocal (C.ContT r) where
55instance LiftLocal (C.ContT r) where
53 liftLocal a l f = C.liftLocal a l f
56 liftLocal a l f = C.liftLocal a l f
57+ {-# INLINE liftLocal #-}
54
58
55instance LiftLocal (E.ExceptT e) where
59instance LiftLocal (E.ExceptT e) where
56 liftLocal _ l f = E.mapExceptT (l f)
60 liftLocal _ l f = E.mapExceptT (l f)
61+ {-# INLINE liftLocal #-}
57
62
58instance LiftLocal I.IdentityT where
63instance LiftLocal I.IdentityT where
59 liftLocal _ l f = I.mapIdentityT (l f)
64 liftLocal _ l f = I.mapIdentityT (l f)
65+ {-# INLINE liftLocal #-}
60
66
61instance LiftLocal L.ListT where
67instance LiftLocal L.ListT where
62 liftLocal _ l f = L.mapListT (l f)
68 liftLocal _ l f = L.mapListT (l f)
69+ {-# INLINE liftLocal #-}
63
70
64instance LiftLocal M.MaybeT where
71instance LiftLocal M.MaybeT where
65 liftLocal _ l f = M.mapMaybeT (l f)
72 liftLocal _ l f = M.mapMaybeT (l f)
73+ {-# INLINE liftLocal #-}
66
74
67instance LiftLocal (R.ReaderT r) where
75instance LiftLocal (R.ReaderT r) where
68 liftLocal _ l f = R.mapReaderT (l f)
76 liftLocal _ l f = R.mapReaderT (l f)
77+ {-# INLINE liftLocal #-}
69
78
70instance Monoid w => LiftLocal (RWS.Lazy.RWST r w s) where
79instance Monoid w => LiftLocal (RWS.Lazy.RWST r w s) where
71 liftLocal _ l f = RWS.Lazy.mapRWST (l f)
80 liftLocal _ l f = RWS.Lazy.mapRWST (l f)
81+ {-# INLINE liftLocal #-}
72
82
73instance Monoid w => LiftLocal (RWS.Strict.RWST r w s) where
83instance Monoid w => LiftLocal (RWS.Strict.RWST r w s) where
74 liftLocal _ l f = RWS.Strict.mapRWST (l f)
84 liftLocal _ l f = RWS.Strict.mapRWST (l f)
85+ {-# INLINE liftLocal #-}
86+
87+instance Monoid w => LiftLocal (RWS.CPS.RWST r w s) where
88+ liftLocal _ l f = RWS.CPS.mapRWST (l f)
89+ {-# INLINE liftLocal #-}
75
90
76instance LiftLocal (S.Lazy.StateT s) where
91instance LiftLocal (S.Lazy.StateT s) where
77 liftLocal _ l f = S.Lazy.mapStateT (l f)
92 liftLocal _ l f = S.Lazy.mapStateT (l f)
93+ {-# INLINE liftLocal #-}
78
94
79instance LiftLocal (S.Strict.StateT s) where
95instance LiftLocal (S.Strict.StateT s) where
80 liftLocal _ l f = S.Strict.mapStateT (l f)
96 liftLocal _ l f = S.Strict.mapStateT (l f)
97+ {-# INLINE liftLocal #-}
81
98
82instance Monoid w => LiftLocal (W.Lazy.WriterT w) where
99instance Monoid w => LiftLocal (W.Lazy.WriterT w) where
83 liftLocal _ l f = W.Lazy.mapWriterT (l f)
100 liftLocal _ l f = W.Lazy.mapWriterT (l f)
101+ {-# INLINE liftLocal #-}
84
102
85instance Monoid w => LiftLocal (W.Strict.WriterT w) where
103instance Monoid w => LiftLocal (W.Strict.WriterT w) where
86 liftLocal _ l f = W.Strict.mapWriterT (l f)
104 liftLocal _ l f = W.Strict.mapWriterT (l f)
105+ {-# INLINE liftLocal #-}
106+
107+instance Monoid w => LiftLocal (W.CPS.WriterT w) where
108+ liftLocal _ l f = W.CPS.mapWriterT (l f)
109+ {-# INLINE liftLocal #-}
110+
111+instance Monoid w => LiftLocal (Acc.AccumT w) where
112+ liftLocal _ l f = Acc.mapAccumT (l f)
113+ {-# INLINE liftLocal #-}
src/Control/Monad/Trans/Lift/Pass.hs+39−10
@@ -15,16 +15,19 @@ import Data.Monoid
15import Control.Monad.Signatures
15import Control.Monad.Signatures
16import Control.Monad.Trans.Class
16import Control.Monad.Trans.Class
17
17
18−import qualified Control.Monad.Trans.Except as E
18+import qualified Control.Monad.Trans.Except as E
19−import qualified Control.Monad.Trans.Identity as I
19+import qualified Control.Monad.Trans.Identity as I
20−import qualified Control.Monad.Trans.Maybe as M
20+import qualified Control.Monad.Trans.Maybe as M
21−import qualified Control.Monad.Trans.Reader as R
21+import qualified Control.Monad.Trans.Reader as R
22−import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
22+import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
23−import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
23+import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
24+import qualified Control.Monad.Trans.RWS.CPS.Internal as RWS.CPS
24−import qualified Control.Monad.Trans.State.Lazy as S.Lazy
25+import qualified Control.Monad.Trans.State.Lazy as S.Lazy
25−import qualified Control.Monad.Trans.State.Strict as S.Strict
26+import qualified Control.Monad.Trans.State.Strict as S.Strict
26−import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
27+import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
27−import qualified Control.Monad.Trans.Writer.Strict as W.Strict
28+import qualified Control.Monad.Trans.Writer.Strict as W.Strict
29+import qualified Control.Monad.Trans.Writer.CPS.Internal as W.CPS
30+import qualified Control.Monad.Trans.Accum as Acc
28
31
29import Control.Monad.Trans.Lift.StT
32import Control.Monad.Trans.Lift.StT
30
33
@@ -50,38 +53,64 @@ defaultLiftPass t unT pass m = t $ liftPass pass (unT m)
50
53
51instance LiftPass (E.ExceptT e) where
54instance LiftPass (E.ExceptT e) where
52 liftPass = E.liftPass
55 liftPass = E.liftPass
56+ {-# INLINE liftPass #-}
53
57
54instance LiftPass I.IdentityT where
58instance LiftPass I.IdentityT where
55 liftPass = I.mapIdentityT
59 liftPass = I.mapIdentityT
60+ {-# INLINE liftPass #-}
56
61
57instance LiftPass M.MaybeT where
62instance LiftPass M.MaybeT where
58 liftPass = M.liftPass
63 liftPass = M.liftPass
64+ {-# INLINE liftPass #-}
59
65
60instance LiftPass (R.ReaderT r) where
66instance LiftPass (R.ReaderT r) where
61 liftPass = R.mapReaderT
67 liftPass = R.mapReaderT
68+ {-# INLINE liftPass #-}
62
69
63instance LiftPass (S.Lazy.StateT s) where
70instance LiftPass (S.Lazy.StateT s) where
64 liftPass = S.Lazy.liftPass
71 liftPass = S.Lazy.liftPass
72+ {-# INLINE liftPass #-}
65
73
66instance LiftPass (S.Strict.StateT s) where
74instance LiftPass (S.Strict.StateT s) where
67 liftPass = S.Strict.liftPass
75 liftPass = S.Strict.liftPass
76+ {-# INLINE liftPass #-}
68
77
69instance Monoid w' => LiftPass (RWS.Lazy.RWST r w' s) where
78instance Monoid w' => LiftPass (RWS.Lazy.RWST r w' s) where
70 liftPass pass m = RWS.Lazy.RWST $ \r s -> pass $ do
79 liftPass pass m = RWS.Lazy.RWST $ \r s -> pass $ do
71 ~((a, f), w', s') <- RWS.Lazy.runRWST m r s
80 ~((a, f), w', s') <- RWS.Lazy.runRWST m r s
72 return ((a, w', s'), f)
81 return ((a, w', s'), f)
82+ {-# INLINE liftPass #-}
73
83
74instance Monoid w' => LiftPass (RWS.Strict.RWST r w' s) where
84instance Monoid w' => LiftPass (RWS.Strict.RWST r w' s) where
75 liftPass pass m = RWS.Strict.RWST $ \r s -> pass $ do
85 liftPass pass m = RWS.Strict.RWST $ \r s -> pass $ do
76 ((a, f), w', s') <- RWS.Strict.runRWST m r s
86 ((a, f), w', s') <- RWS.Strict.runRWST m r s
77 return ((a, w', s'), f)
87 return ((a, w', s'), f)
88+ {-# INLINE liftPass #-}
89+
90+instance Monoid w' => LiftPass (RWS.CPS.RWST r w' s) where
91+ liftPass pass m = RWS.CPS.RWST $ \r w_ s -> pass $ do
92+ ((a, f), w', s') <- RWS.CPS.unRWST m r w_ s
93+ return ((a, w', s'), f)
94+ {-# INLINE liftPass #-}
78
95
79instance Monoid w' => LiftPass (W.Lazy.WriterT w') where
96instance Monoid w' => LiftPass (W.Lazy.WriterT w') where
80 liftPass pass m = W.Lazy.WriterT $ pass $ do
97 liftPass pass m = W.Lazy.WriterT $ pass $ do
81 ~((a, f), w') <- W.Lazy.runWriterT m
98 ~((a, f), w') <- W.Lazy.runWriterT m
82 return ((a, w'), f)
99 return ((a, w'), f)
100+ {-# INLINE liftPass #-}
83
101
84instance Monoid w' => LiftPass (W.Strict.WriterT w') where
102instance Monoid w' => LiftPass (W.Strict.WriterT w') where
85 liftPass pass m = W.Strict.WriterT $ pass $ do
103 liftPass pass m = W.Strict.WriterT $ pass $ do
86 ((a, f), w') <- W.Strict.runWriterT m
104 ((a, f), w') <- W.Strict.runWriterT m
87 return ((a, w'), f)
105 return ((a, w'), f)
106+ {-# INLINE liftPass #-}
107+
108+instance Monoid w' => LiftPass (W.CPS.WriterT w') where
109+ liftPass pass m = W.CPS.WriterT $ \w_ -> pass $ do
110+ ((a, f), w') <- W.CPS.unWriterT m w_
111+ return ((a, w'), f)
112+ {-# INLINE liftPass #-}
113+
114+instance Monoid w' => LiftPass (Acc.AccumT w') where
115+ liftPass = Acc.liftPass
116+ {-# INLINE liftPass #-}
src/Control/Monad/Trans/Lift/StT.hs+7−1
@@ -10,10 +10,13 @@ import qualified Control.Monad.Trans.Maybe as M
10import qualified Control.Monad.Trans.Reader as R
10import qualified Control.Monad.Trans.Reader as R
11import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
11import qualified Control.Monad.Trans.RWS.Lazy as RWS.Lazy
12import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
12import qualified Control.Monad.Trans.RWS.Strict as RWS.Strict
13+import qualified Control.Monad.Trans.RWS.CPS as RWS.CPS
13import qualified Control.Monad.Trans.State.Lazy as S.Lazy
14import qualified Control.Monad.Trans.State.Lazy as S.Lazy
14import qualified Control.Monad.Trans.State.Strict as S.Strict
15import qualified Control.Monad.Trans.State.Strict as S.Strict
15import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
16import qualified Control.Monad.Trans.Writer.Lazy as W.Lazy
16import qualified Control.Monad.Trans.Writer.Strict as W.Strict
17import qualified Control.Monad.Trans.Writer.Strict as W.Strict
18+import qualified Control.Monad.Trans.Writer.CPS as W.CPS
19+import qualified Control.Monad.Trans.Accum as Acc
17
20
18-- | Internal state of a monad transformer.
21-- | Internal state of a monad transformer.
19-- Same as @StT@ from the @monad-control@ package.
22-- Same as @StT@ from the @monad-control@ package.
@@ -26,7 +29,10 @@ type instance StT M.MaybeT a = Maybe a
26type instance StT (R.ReaderT r) a = a
29type instance StT (R.ReaderT r) a = a
27type instance StT (RWS.Lazy.RWST r w s) a = (a, s, w)
30type instance StT (RWS.Lazy.RWST r w s) a = (a, s, w)
28type instance StT (RWS.Strict.RWST r w s) a = (a, s, w)
31type instance StT (RWS.Strict.RWST r w s) a = (a, s, w)
32+type instance StT (RWS.CPS.RWST r w s) a = (a, s, w)
29type instance StT (S.Lazy.StateT s) a = (a, s)
33type instance StT (S.Lazy.StateT s) a = (a, s)
30type instance StT (S.Strict.StateT s) a = (a, s)
34type instance StT (S.Strict.StateT s) a = (a, s)
31−type instance StT (W.Strict.WriterT w) a = (a, w)
32type instance StT (W.Lazy.WriterT w) a = (a, w)
35type instance StT (W.Lazy.WriterT w) a = (a, w)
36+type instance StT (W.Strict.WriterT w) a = (a, w)
37+type instance StT (W.CPS.WriterT w) a = (a, w)
38+type instance StT (Acc.AccumT w) a = (a, w)
transformers-lift.cabal+4−3
@@ -1,5 +1,5 @@
1name: transformers-lift
1name: transformers-lift
2−version: 0.1.0.1
2+version: 0.2.0.0
3synopsis: Ad-hoc type classes for lifting
3synopsis: Ad-hoc type classes for lifting
4description:
4description:
5 This simple and lightweight library provides type classes
5 This simple and lightweight library provides type classes
@@ -23,7 +23,8 @@ library
23 Control.Monad.Trans.Lift.StT
23 Control.Monad.Trans.Lift.StT
24
24
25 build-depends: base >=4.6 && <4.11
25 build-depends: base >=4.6 && <4.11
26− , transformers >= 0.4.2
26+ , transformers >= 0.5.4.0
27+ , writer-cps-transformers >= 0.1.1.3
27
28
28 default-language: Haskell2010
29 default-language: Haskell2010
29 other-extensions: CPP
30 other-extensions: CPP
@@ -32,4 +33,4 @@ library
32 KindSignatures
33 KindSignatures
33
34
34 hs-source-dirs: src
35 hs-source-dirs: src
35− ghc-options: -Wall
36+ ghc-options: -Wall -fno-warn-deprecations