@@ -25,15 +25,12 @@ module Control.Monad.Trans.Ether.Writer
28− -- * Lifting other operations
32#if __GLASGOW_HASKELL__ < 710
30#if __GLASGOW_HASKELL__ < 710
33import Data.Monoid
31import Data.Monoid
36−import Data.Proxy (Proxy(Proxy))
37import Data.Functor.Identity (Identity(..))
34import Data.Functor.Identity (Identity(..))
38import Data.Coerce (coerce)
35import Data.Coerce (coerce)
39import Control.Applicative
36import Control.Applicative
@@ -46,7 +43,6 @@ import Control.Ether.Tagged (Taggable(..), Tagged(..))
46import GHC.Generics (Generic)
43import GHC.Generics (Generic)
47import qualified Control.Newtype as NT
44import qualified Control.Newtype as NT
49−import qualified Control.Monad.Signatures as Sig
50import qualified Control.Monad.Trans.Control as MC
46import qualified Control.Monad.Trans.Control as MC
51import qualified Control.Monad.Trans.Writer.Lazy as Trans
47import qualified Control.Monad.Trans.Writer.Lazy as Trans
@@ -54,6 +50,7 @@ import qualified Control.Monad.Trans.Lift.Local as Lift
54import qualified Control.Monad.Trans.Lift.Catch as Lift
50import qualified Control.Monad.Trans.Lift.Catch as Lift
55import qualified Control.Monad.Trans.Lift.Listen as Lift
51import qualified Control.Monad.Trans.Lift.Listen as Lift
56import qualified Control.Monad.Trans.Lift.Pass as Lift
52import qualified Control.Monad.Trans.Lift.Pass as Lift
53+import qualified Control.Monad.Trans.Lift.CallCC as Lift
58import qualified Control.Monad.Cont.Class as Class
55import qualified Control.Monad.Cont.Class as Class
59import qualified Control.Monad.Reader.Class as Class
56import qualified Control.Monad.Reader.Class as Class
@@ -94,6 +91,9 @@ instance Monoid w' => Lift.LiftListen (WriterT tag w') where
94instance Monoid w' => Lift.LiftPass (WriterT tag w') where
91instance Monoid w' => Lift.LiftPass (WriterT tag w') where
95 liftPass pass m = WriterT $ Lift.liftPass pass (coerce m)
92 liftPass pass m = WriterT $ Lift.liftPass pass (coerce m)
94+instance Monoid w => Lift.LiftCallCC (WriterT tag w) where
95+ liftCallCC callCC f = WriterT $ Lift.liftCallCC callCC (coerce f)
97instance Taggable (WriterT tag w m) where
97instance Taggable (WriterT tag w m) where
98 type Tag (WriterT tag w m) = 'Just tag
98 type Tag (WriterT tag w m) = 'Just tag
99 type Inner (WriterT tag w m) = 'Just m
99 type Inner (WriterT tag w m) = 'Just m
@@ -130,9 +130,6 @@ execWriterT t = Trans.execWriterT . untagged t
130execWriter :: proxy tag -> Writer tag w a -> w
130execWriter :: proxy tag -> Writer tag w a -> w
131execWriter t = Trans.execWriter . untagged t
131execWriter t = Trans.execWriter . untagged t
133−-- | Transform the computation inside a 'WriterT'.
136-- | Appends a value to the accumulator within the monad.
133-- | Appends a value to the accumulator within the monad.
137tell :: Monad m => proxy tag -> w -> WriterT tag w m ()
134tell :: Monad m => proxy tag -> w -> WriterT tag w m ()
138tell t w = writer t ((), w)
135tell t w = writer t ((), w)
@@ -146,12 +143,8 @@ listen t m = tagged t $ Trans.listen (coerce m)
146pass :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a
143pass :: (Monoid w, Monad m) => proxy tag -> WriterT tag w m (a, w -> w) -> WriterT tag w m a
147pass t m = tagged t $ Trans.pass (coerce m)
144pass t m = tagged t $ Trans.pass (coerce m)
149−-- | Lift a @callCC@ operation to the new monad.
150−liftCallCC :: Monoid w => proxy tag -> Sig.CallCC m (a, w) (b, w) -> Sig.CallCC (WriterT tag w m) a b
151−liftCallCC t callCC f = tagged t $ Trans.liftCallCC callCC (coerce f)
153instance (Monoid w, Class.MonadCont m) => Class.MonadCont (WriterT tag w m) where
146instance (Monoid w, Class.MonadCont m) => Class.MonadCont (WriterT tag w m) where
154− callCC = liftCallCC Proxy Class.callCC
147+ callCC = Lift.liftCallCC Class.callCC
156instance (Monoid w, Class.MonadReader r m) => Class.MonadReader r (WriterT tag w m) where
149instance (Monoid w, Class.MonadReader r m) => Class.MonadReader r (WriterT tag w m) where
157 ask = lift Class.ask
150 ask = lift Class.ask