[Haskell-cafe] Lifting Writer to ListT

Nicola Gigante nicola.gigante at gmail.com
Tue Mar 3 11:03:50 UTC 2015

Hi all,

Suppose I have this monad stack:

type MyMonad = ListT (Writer W)

Where ListT is done right (from the list-t package). 
What I want is a nondeterministic computation where each 
alternative logs to the same writer, and indeed the type of

runWriter . toList

is MyMonad a -> ([a], w)

so I think I got it right.

What I would like to do is to write an instance of MonadWriter 
for this monad, but I'm stuck with the implementation of listen.

Just using lift won't work, and indeed I see that MonadWriter 
lifting instances for other monads (e.g MaybeT), are a bit convoluted.

Could someone explain me a little bit what should I do (what 
listen should do in a ListT in the first place)

Thank you :)

More information about the Haskell-Cafe mailing list