[Haskell-cafe] Re: Top Level TWI's again was Re: [Haskell] Re: Parameterized Show

Graham Klyne GK at ninebynine.org
Mon Nov 22 15:32:33 EST 2004


[Switching to Haskell-cafe]

At 11:26 22/11/04 +0000, you wrote:
>I would ask an alternative question - is it possible to live without
>unsafePerformIO? I have never needed to use it!

I have used it once, with reservations, but at the time I didn't have the 
time/energy to find a better solution.  (The occasion of its use was 
accessing external entities within an XML parser;  by making the assumption 
that the external entities do not change within any context in which 
results from a program are compared, I was able to satisfy the "proof 
obligation" of not causing or being sensitive to side effects.)

The reason this was important to me is that I wanted to be able to use the 
parser from code that was not visibly in the IO monad.  For me, treating 
Web data transformations as pure functions is one of the attractions of 
using Haskell.

(Since doing that, I had an idea that I might be able to parameterize the 
entity processing code on some Monad, and use either an Identity monad or 
IO depending on the actual requirements.  This way, I could keep pure XML 
processing out of the IO monad, but use IO when IO was needed.)

In short:  I think it's usually possible to avoid using unsafePerformIO, 
but I'd be reluctant to cede it altogether, if only for sometimes 
quick-and-dirty pragmatic reasons.

#g


------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact



More information about the Haskell-Cafe mailing list