Summary

In this chapter we have imported C functions as Haskell functions, exported Haskell functions as C functions, passed pointers (both foreign and stable) and data through the FFI, built a shared library with Haskell, and used hsc2hsto to write a Storable instance for a custom datatype. You have learned to invoke the FFI from both the C and the Haskell side and to manage memory in both the Haskell heap and the lower-level memory area also used by C.

The next chapter will be about another implementation-level concept like the FFI: GPU-programming using Haskell. Graphics processors are much better suited for highly parallel number-crunching applications, which is the reason for the GPU's popularity in high-performance numeric computing. An excellent ...

Get Haskell High Performance Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.