<div dir="ltr">You might prefer using the <a href="https://hackage.haskell.org/package/pipes-4.1.4/docs/Pipes.html#g:5">ListT</a> 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.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 3, 2015 at 6:03 AM, Nicola Gigante <span dir="ltr"><<a href="mailto:nicola.gigante@gmail.com" target="_blank">nicola.gigante@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
Suppose I have this monad stack:<br>
<br>
type MyMonad = ListT (Writer W)<br>
<br>
Where ListT is done right (from the list-t package).<br>
What I want is a nondeterministic computation where each<br>
alternative logs to the same writer, and indeed the type of<br>
<br>
runWriter . toList<br>
<br>
is MyMonad a -> ([a], w)<br>
<br>
so I think I got it right.<br>
<br>
What I would like to do is to write an instance of MonadWriter<br>
for this monad, but I'm stuck with the implementation of listen.<br>
<br>
Just using lift won't work, and indeed I see that MonadWriter<br>
lifting instances for other monads (e.g MaybeT), are a bit convoluted.<br>
<br>
Could someone explain me a little bit what should I do (what<br>
listen should do in a ListT in the first place)<br>
<br>
Thank you :)<br>
Nicola<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>