Blogs (61) >>
Mon 16 Jul 2018 13:50 - 14:30 at Matterhorn III - Track 3

Haskell has a powerful foreign function interface (FFI) for interfacing with C libraries. Haskell is a great language for building libraries and tools, but interoperability requirements or time constraints can make the FFI a compelling option. Binding to a non-trivial C library presents several challenges including C idioms, memory management, error handling and more. This presentation will address a selection of these concerns, using hs-notmuch, a binding to the “notmuch” mail indexer, as a case study. We will discuss: - FFI basics and tools to assist binding authors - working with “double pointer”-style constructors - working with iterators; how to do lazy iteration - how to use Haskell’s garbage collector to manage lifecycles of external objects, and “gotchas” encountered - using types to enforce correct use of unsafe APIs - performance considerations (including profiling results) The presentation will conclude with a mention of some important FFI concepts that were not covered (e.g. callbacks) and a look at how hs-notmuch is being used in the real world. Attendees will leave this presentation confident to write Haskell bindings to many kinds of C libraries. Developers familiar with C will get the most out of this talk (because there will be limited time to explain C idioms, memory management, etc). To varying degrees, most of the concepts and techniques discussed will apply to other languages’ FFIs.

Mon 16 Jul

Displayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change