[Haskell-cafe] HaXmL and the IO Monad

John Goerzen jgoerzen at complete.org
Fri Jan 21 09:53:04 EST 2005


I've been playing with HaXmL lately.  I've had a need to convert one XML
document to another, and HaXmL was very nice for that.

Along the way, I've discovered that I need to do some I/O as part of the
conversion (specifically due to timezone-related calculations).  Much of
HaXML is based around the CFilter type:

type CFilter = Content -> [Content]

That is, most of the stuff one does in HaXML is a function with that
type.

Try as I might, I could not figure out a nice way to integrate I/O into
this system.  A simple IO CFilter wouldn't work, since there has to be
input available when it runs.  Content -> IO [Content] didn't work
either, since the IO ripples up all the way to the top, messing up the
nice code everywhere.

I finally resorted to unsafePerformIO to get it done.  But I'd like to
know the proper solution.  I do hope that this is not it :-)

Thanks,
John




More information about the Haskell-Cafe mailing list