@@ -42,7 +42,8 @@ module Ether.Writer
4242import Control.Monad.Signatures (Listen, Pass)
4343import qualified Control.Monad.Trans.Lift.Listen as Lift
4444import 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
4647import Data.Coerce
4748import Data.Functor.Identity
4849
@@ -117,37 +118,37 @@ type Writer tag w = WriterT tag w Identity
117118--
118119-- The 'return' function produces the output 'mempty', while '>>=' combines
119120-- 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)
121122
122123-- | 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 = coerce (T.WriterT @w @m @a)
124+writerT :: forall tag w m a . (Functor m, Monoid w) => m (a, w) -> WriterT tag w m a
125+writerT = coerce (T.CPS.writerT @m @w @a)
125126
126127-- | Runs a 'WriterT' and returns both the normal value
127128-- and the final accumulator.
128−runWriterT :: forall tag w m a . WriterT tag w m a -> m (a, w)
129−runWriterT = coerce (T.runWriterT @w @m @a)
129+runWriterT :: forall tag w m a . Monoid w => WriterT tag w m a -> m (a, w)
130+runWriterT = coerce (T.CPS.runWriterT @w @m @a)
130131
131132-- | Runs a 'Writer' and returns both the normal value
132133-- and the final accumulator.
133−runWriter :: forall tag w a . Writer tag w a -> (a, w)
134−runWriter = coerce (T.runWriter @w @a)
134+runWriter :: forall tag w a . Monoid w => Writer tag w a -> (a, w)
135+runWriter = coerce (T.CPS.runWriter @w @a)
135136
136137-- | Runs a 'WriterT' and returns the final accumulator,
137138-- discarding the normal value.
138−execWriterT :: forall tag w m a . Monad m => WriterT tag w m a -> m w
139−execWriterT = coerce (T.execWriterT @m @w @a)
139+execWriterT :: forall tag w m a . (Monad m, Monoid w) => WriterT tag w m a -> m w
140+execWriterT = coerce (T.CPS.execWriterT @m @w @a)
140141
141142-- | Runs a 'Writer' and returns the final accumulator,
142143-- discarding the normal value.
143−execWriter :: forall tag w a . Writer tag w a -> w
144−execWriter = coerce (T.execWriter @w @a)
144+execWriter :: forall tag w a . Monoid w => Writer tag w a -> w
145+execWriter = coerce (T.CPS.execWriter @w @a)
145146
146147type instance HandleSuper WRITER w trans = Monoid w
147148type instance HandleConstraint WRITER w trans m =
148149 T.MonadWriter w (trans m)
149150
150−instance Monoid w => Handle WRITER w (T.WriterT w) where
151+instance Monoid w => Handle WRITER w (T.CPS.WriterT w) where
151152 handling r = r
152153 {-# INLINE handling #-}
153154
@@ -182,21 +183,21 @@ instance
182183
183184type Writer' w = Writer w w
184185
185−runWriter' :: Writer' w a -> (a, w)
186+runWriter' :: Monoid w => Writer' w a -> (a, w)
186187runWriter' = runWriter
187188
188−execWriter' :: Writer' w a -> w
189+execWriter' :: Monoid w => Writer' w a -> w
189190execWriter' = execWriter
190191
191192type WriterT' w = WriterT w w
192193
193−writerT' :: m (a, w) -> WriterT' w m a
194+writerT' :: (Functor m, Monoid w) => m (a, w) -> WriterT' w m a
194195writerT' = writerT
195196
196−runWriterT' :: WriterT' w m a -> m (a, w)
197+runWriterT' :: Monoid w => WriterT' w m a -> m (a, w)
197198runWriterT' = runWriterT
198199
199−execWriterT' :: Monad m => WriterT' w m a -> m w
200+execWriterT' :: (Monad m, Monoid w) => WriterT' w m a -> m w
200201execWriterT' = execWriterT
201202
202203type MonadWriter' w = MonadWriter w w