@@ -42,7 +42,8 @@ module Ether.Writer
42import Control.Monad.Signatures (Listen, Pass)
42import Control.Monad.Signatures (Listen, Pass)
43import qualified Control.Monad.Trans.Lift.Listen as Lift
43import qualified Control.Monad.Trans.Lift.Listen as Lift
44import qualified Control.Monad.Trans.Lift.Pass as Lift
44import qualified Control.Monad.Trans.Lift.Pass as Lift
45−import qualified Control.Monad.Writer as T
45+import qualified Control.Monad.Writer.Class as T
46+import qualified Control.Monad.Writer.CPS as T.CPS
46import Data.Coerce
47import Data.Coerce
47import Data.Functor.Identity
48import Data.Functor.Identity
@@ -117,37 +118,37 @@ type Writer tag w = WriterT tag w Identity
118-- The 'return' function produces the output 'mempty', while '>>=' combines
119-- The 'return' function produces the output 'mempty', while '>>=' combines
119-- the outputs of the subcomputations using 'mappend'.
120-- the outputs of the subcomputations using 'mappend'.
120−type WriterT tag w = TaggedTrans (TAGGED WRITER tag) (T.WriterT w)
121+type WriterT tag w = TaggedTrans (TAGGED WRITER tag) (T.CPS.WriterT w)
122-- | Constructor for computations in the writer monad transformer.
123-- | Constructor for computations in the writer monad transformer.
123−writerT :: forall tag w m a . m (a, w) -> WriterT tag w m a
124+writerT :: forall tag w m a . (Functor m, Monoid w) => m (a, w) -> WriterT tag w m a
124−writerT = coerce (T.WriterT @w @m @a)
125+writerT = coerce (T.CPS.writerT @m @w @a)
126-- | Runs a 'WriterT' and returns both the normal value
127-- | Runs a 'WriterT' and returns both the normal value
127-- and the final accumulator.
128-- and the final accumulator.
128−runWriterT :: forall tag w m a . WriterT tag w m a -> m (a, w)
129+runWriterT :: forall tag w m a . Monoid w => WriterT tag w m a -> m (a, w)
129−runWriterT = coerce (T.runWriterT @w @m @a)
130+runWriterT = coerce (T.CPS.runWriterT @w @m @a)
131-- | Runs a 'Writer' and returns both the normal value
132-- | Runs a 'Writer' and returns both the normal value
132-- and the final accumulator.
133-- and the final accumulator.
133−runWriter :: forall tag w a . Writer tag w a -> (a, w)
134+runWriter :: forall tag w a . Monoid w => Writer tag w a -> (a, w)
134−runWriter = coerce (T.runWriter @w @a)
135+runWriter = coerce (T.CPS.runWriter @w @a)
136-- | Runs a 'WriterT' and returns the final accumulator,
137-- | Runs a 'WriterT' and returns the final accumulator,
137-- discarding the normal value.
138-- discarding the normal value.
138−execWriterT :: forall tag w m a . Monad m => WriterT tag w m a -> m w
139+execWriterT :: forall tag w m a . (Monad m, Monoid w) => WriterT tag w m a -> m w
139−execWriterT = coerce (T.execWriterT @m @w @a)
140+execWriterT = coerce (T.CPS.execWriterT @m @w @a)
141-- | Runs a 'Writer' and returns the final accumulator,
142-- | Runs a 'Writer' and returns the final accumulator,
142-- discarding the normal value.
143-- discarding the normal value.
143−execWriter :: forall tag w a . Writer tag w a -> w
144+execWriter :: forall tag w a . Monoid w => Writer tag w a -> w
144−execWriter = coerce (T.execWriter @w @a)
145+execWriter = coerce (T.CPS.execWriter @w @a)
146type instance HandleSuper WRITER w trans = Monoid w
147type instance HandleSuper WRITER w trans = Monoid w
147type instance HandleConstraint WRITER w trans m =
148type instance HandleConstraint WRITER w trans m =
148 T.MonadWriter w (trans m)
149 T.MonadWriter w (trans m)
150−instance Monoid w => Handle WRITER w (T.WriterT w) where
151+instance Monoid w => Handle WRITER w (T.CPS.WriterT w) where
151 handling r = r
152 handling r = r
152 {-# INLINE handling #-}
153 {-# INLINE handling #-}
@@ -182,21 +183,21 @@ instance
183type Writer' w = Writer w w
184type Writer' w = Writer w w
185−runWriter' :: Writer' w a -> (a, w)
186+runWriter' :: Monoid w => Writer' w a -> (a, w)
186runWriter' = runWriter
187runWriter' = runWriter
188−execWriter' :: Writer' w a -> w
189+execWriter' :: Monoid w => Writer' w a -> w
189execWriter' = execWriter
190execWriter' = execWriter
191type WriterT' w = WriterT w w
192type WriterT' w = WriterT w w
193−writerT' :: m (a, w) -> WriterT' w m a
194+writerT' :: (Functor m, Monoid w) => m (a, w) -> WriterT' w m a
194writerT' = writerT
195writerT' = writerT
196−runWriterT' :: WriterT' w m a -> m (a, w)
197+runWriterT' :: Monoid w => WriterT' w m a -> m (a, w)
197runWriterT' = runWriterT
198runWriterT' = runWriterT
199−execWriterT' :: Monad m => WriterT' w m a -> m w
200+execWriterT' :: (Monad m, Monoid w) => WriterT' w m a -> m w
200execWriterT' = execWriterT
201execWriterT' = execWriterT
202type MonadWriter' w = MonadWriter w w
203type MonadWriter' w = MonadWriter w w