Foreign Exchange at Low, Low Rates A lightweight, platform-agnostic FFI for high level Haskell
Anton Ekblad · 2015
We present a novel yet simple foreign function interface for Haskell dialects targeting high level platforms. The interface automates marshalling, eliminates boilerplate code, allows increased sanity checking of external data, and is implementable as a plain Haskell ’98 library across a range of Haskell compilers and host environments without any modification to the compiler or environment. We give an implementation of this interface for the JavaScripttargeting Haste compiler, and show how the basic implementation can be further optimized with minimal effort to perform on par with Haskell’s vanilla foreign function interface, as well as extended to support automatic marshalling of functions and modified to support a larger range of host environments at the cost of a slight increase in implementation complexity.