[Haskell-beginners] How to unnest "do"
Emmanuel Touzery
etouzery at gmail.com
Sun Jan 27 21:29:27 CET 2013
> stats :: String -> String
> stats =
> unwords .
> sequence [show . length . words,
> show . length . lines,
> show . length]
>
>
[..]
> This improves the statistics code slightly, but uses some monadic
> machinery you may not be familiar with. Another way to read the 'stats'
> function is this:
>
> stats :: String -> String
> stats str =
> unwords [show . length . words $ str,
> show . length . lines $ str,
> show . length $ str]
>
I'm sorry, may I ask on which monad here is "sequence" operating?
I can see that sequence here turns [a->a] into a->[a], I'm just not sure
which is the monad at play here... I just need a little bit more
explanation about this code before I get it.
Thank you!
Emmanuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130127/b50928dd/attachment.htm>
More information about the Beginners
mailing list