wiki:ForeignFunctionInterface

Version 2 (modified by ross@…, 8 years ago) (diff)

Delenda est Carthago

Foreign Function Interface

See ExtensionDescriptionHowto for information on how to write these extension descriptions. Please add any new extensions to the list of HaskellExtensions.

Brief Explanation

Adds support for invoking code written in other programming languages from Haskell and vice versa. The FFI is designed as a non-intrusive extension to the Haskell 98 standard.

References

Pros

  • Widely accepted and used addendum.
  • Provides an essential facility.

Cons

  • Some feel that the inclusion of unsafePerformIO sends the wrong signal.
    • It is true that giving inaccurate foreign imports can invalidate all guarantees given by Haskell, including providing a way to define unsafePerformIO, but that doesn't mean it should be standard.
    • The stated purpose of unsafePerformIO in the FFI (hiding marshalling and unmarshalling for otherwise pure functions) can be achieved with a runST-like device if the language has Rank2Types or RankNTypes.