In theory, this should be possible--as with most other languages, Haskell (using in this case the Glasgow Haskell Compiler) compiles source files into object files which are then linked by the system linker into a compiled program (in actuality, the ghc command shells out to all these system programs and is rather difficult to tinker with, a problem which will cost us something in the next section).

The problem is that Haskell functions are not easily given a foreign interface--at least, not by default. GHC supports a special Foreign Function Interface (FFI), which does make this sort of thing possible, but it requires some legwork and is specific to GHC.

As it happens, though, there is a somewhat more formal and generic way to go about this. HaskellDirect is a library and Interface Definition Language (IDL) compiler for Haskell by Sigbjorn Finne and Daan Leijen which, like SWIG, makes C functions available to Haskell-and vice versa. Developers write an IDL specification for a given module, run the ihc program from HaskellDirect on it, link the results with the HaskellDirect supporting library, and have, for example, Haskell functions available via C. The HaskellDirect supporting library handles the task of marshaling structures (such as C arrays) to and from Haskell-compatible data structures. In theory, this would allow us to then take the C-compatible exported functions and, using SWIG, export them to Eiffel (or Python, but our example will focus on Eiffel).

Because our interest here is in using Eiffel control and flow structures with Haskell functions called as a supporting library, we won't do much exploration of using Haskell to control Eiffel components, which would seem to play on the weaknesses of both languages instead of their strengths.