[Haskell-cafe] Issues with IO and FFIs
Bertram Felgenhauer
bertram.felgenhauer at googlemail.com
Wed Apr 22 06:09:36 EDT 2009
Jon Harrop wrote:
>
> Does anyone have any comments on the following criticism of some
> difficulties with FFI, including IO, in Haskell:
>
> http://groups.google.com/group/comp.lang.functional/msg/6d650c086b2c8a49?hl=en
That post conflates two separate questions.
1) binding to foreign libraries that export functions that are
semantically pure, but can't be imported as pure functions, for
example because they use pointers.
unsafePerformIO was added in the FFI spec for exactly this purpose,
as you can see for yourself here:
http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise5.html#x8-240005.1
2) global variables. This has been a topic of long and heated debates,
with no clear winner. I don't think another debate will be fruitful.
> In particular, is it not always possible to write IO libraries safely in
> Haskell?
Flame bait? Yes, it is not always possible, because some interfaces are
inherently unsafe, putting the burden of using them safely on the user.
unsafePerformIO itself is a prime example for this.
Bertram
More information about the Haskell-Cafe
mailing list