[Haskell-beginners] ListT + Writer
Baa
aquagnu at gmail.com
Fri May 26 08:16:37 UTC 2017
@Francesco, yes, it completely answers my questions. Thank you very much
for clarification!! I got it.
В Thu, 25 May 2017 20:44:57 +0200
Francesco Ariis <fa-ml at ariis.it> пишет:
> On Thu, May 25, 2017 at 07:02:58PM +0300, Baa wrote:
> >
> > В Thu, 25 May 2017 17:43:49 +0200
> > > Should be as easy as:
> > >
> > > import Control.Monad.List
> > > import Control.Monad.Writer
> > >
> > > type Prova = ListT (Writer String) Int
> >
> > Yes! And this is the source of my questions.. 1) How to call it? 2)
> > What does mean to provide argument of type ".. Writer .."? As
> > result, it's good: you can run it with "runWriter", but what is
> > "writer" in input argument? Fake writer (which is ignoring)?
>
> I am not sure for question #1. If we look at the constructor of ListT
> (`runListT :: m [a]`) and MonadWriter (`(a, w)`) and we compose the
> two we get:
>
> ([a], w)
> -- or ([Integer], String) in our example
> -- e.g. ListT (writer ([1,2], "ciao")) <-- to construct
>
> No idea what is the correct name of this critter.
>
> As we can see by running it, the argument in `fn` (both the list part
> and the string part) is not ignored:
>
> λ> fn $ ListT (writer ([1,2], "ciao"))
> ListT (WriterT (Identity ([3],"ciaohey baby")))
>
> Does this answer your questions?
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
More information about the Beginners
mailing list