unsafePerformIO around FFI calls
08 Jul 2002 20:04:14 +0100
Hal Daume <hdaume@ISI.EDU> writes:
> I'm curious exactly what is "safe" and what is "unsafe" to wrap
> unsafePerformIO around when it comes to FFI calls.
Here's a simple test:
Could you imagine an alternative implementation of the same API in
pure Haskell? (Don't consider efficiency or effort required to write
the implementation, just whether it can be done.)
If so, then it is ok to use unsafePerformIO and the ffi to implement
the API instead.
If it fails that test, it is incredibly unlikely that it is ok and a
proof that it is ok is likely to be pretty complex - maybe worth a
PLDI paper or some such.
Alastair Reid firstname.lastname@example.org
Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/