
3 Mar
2015
3 Mar
'15
6:03 a.m.
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