[Haskell-beginners] ListT + Writer

Baa aquagnu at gmail.com
Thu May 25 16:02:58 UTC 2017


В Thu, 25 May 2017 17:43:49 +0200
Francesco Ariis <fa-ml at ariis.it> пишет:

> On Thu, May 25, 2017 at 06:10:27PM +0300, Baa wrote:
> >   fn :: [a] -> [a]
> >   fn lst = do
> >     el <- lst
> >     guard $ condition el
> >     ...
> >     return $ change el
> > 
> > How can I do the same but with possibility to call "tell" of "Write"
> > monad in the fn's body? As I understand it should be:  
> 
> Should be as easy as:
> 
>     import Control.Monad.List
>     import Control.Monad.Writer
> 
>     type Prova = ListT (Writer String) Int
> 
>     fn :: Prova -> Prova
>     fn lst = do el <- lst
>                 guard (rem el 2 == 0)
>                 lift $ tell "hey bby"
>                 return (el + 1)

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)?


> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners



More information about the Beginners mailing list