You might prefer using the ListT implementation from the Pipes package which has instances for MonadReader, MonadWriter, and MonadState already. Also, the provided source might give you some insight into how to write these instances for the list-t:ListT type.

On Tue, Mar 3, 2015 at 6:03 AM, Nicola Gigante <nicola.gigante@gmail.com> wrote:
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 :)
Nicola


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe