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

Luke Palmer lrpalmer at gmail.com
Tue Apr 14 11:01:37 EDT 2009


On Tue, Apr 14, 2009 at 8: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?
>
This is very important: you cannot.

But you can still get your hands on one inside a do block.  As in, if you
have tree :: IO [XmlTree], then you can say, eg.

printTree = do
    t <- tree
    print t

Inside this block, t is an [XmlTree], and it is passed to print. Intutively,
when you see

 x <- y

inside a do block, if y :: IO a, for some type a, then x :: a.

But there is no function that will get you from IO [XmlTree] -> [XmlTree],
you have to use binding like this.

Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090414/7fbef14b/attachment.htm


More information about the Haskell-Cafe mailing list