Proposal: add new forms of unsafePerformIO and unsafeInterleaveIO

Duncan Coutts duncan.coutts at
Fri Feb 22 05:51:12 EST 2008

On Thu, 2008-02-14 at 12:00 -0800, John Meacham wrote:
> I mildly prefer 'Idempotent' to 'Dupable'. feels more descriptive to me.
> This is even useful in jhc without threading, as expressions can be
> marked 'idempotent and cheap' giving the compiler freedom to duplicate
> them when it makes sense.

It's a fair point. I don't really mind, if other people prefer that name
then fine.

> However, I am worried about the 'Inline' in the other one, in jhc,
> unsafePerformIO is always inlined, it uses a different trick (my
> 'dependingOn' primitive) to ensure the world is not unified with another
> one. 
> Can we come up with a term that describes the difference other than
> 'inline' as that is a ghc specific quirk.

Mm, you're right, it is ghc specific. The semantics are less to do with
inlining (though that's the perf advantage) and more about doing
dangerous things with the world token.

Can anyone suggest a better name?

> incidentally, jhc has another form of unsafePerformIO that does not wrap
> its argument in a new exception handler. It can be used when you know
> the argument won't raise an ioError or if it does, it handles them
> itself. (normal calls to things like error and pattern match failures
> are fine. it is just haskell98 io errors that metter for this one)

Right, GHC misses this once because it doesn't wrap any in an exception
handler since its exception mechanism for IO errors is the same as for
'error'. If you have a good name and documentation then propose it now.


More information about the Libraries mailing list