[Haskell-cafe] Converting IO [XmlTree] to [XmlTree]

Gwern Branwen gwern0 at gmail.com
Tue Apr 14 11:25:19 EDT 2009


On Tue, Apr 14, 2009 at 10:54 AM, rodrigo.bonifacio
<rodrigo.bonifacio at uol.com.br> wrote:
> Dear Sirs,
>
> I guess this is a very simple question. How can I convert IO [XmlTree] to
> just a list of XmlTree?
>
> Regards,
>
> Rodrigo.

One good link on this topic is http://haskell.org/haskellwiki/Avoiding_IO

Maybe there's no need for it be be IO [XmlTree], if you can write
functions that instead produce/consume just [XmlTree]. They can always
be turned later with liftM and whatnot into a IO [XmlTree] (but not
the reverse).

Doing as much as possible in pure code, and wrapping around it/calling
it from a few short IO functions is the Haskell Way. Sometimes it
looks hard to see, but XMonad is probably the best example here of how
it can both be done where it looks infeasible ('What's a window
manager but a bunch of IO?") and is rewarding (testability, etc. as
exemplified by http://cgi.cse.unsw.edu.au/~dons/blog/2007/05/17) The
best writeup on this seems to be
http://www.cse.unsw.edu.au/~dons/talks/xmonad-hw07.pdf

-- 
gwern


More information about the Haskell-Cafe mailing list