[Haskell-cafe] Lifting Writer to ListT
nrujac at gmail.com
Tue Mar 3 16:22:49 UTC 2015
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
On Tue, Mar 3, 2015 at 6:03 AM, Nicola Gigante <nicola.gigante at gmail.com>
> 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 :)
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe