Automatic C bindings generation for Haskell
summary
hs-bindgen automatically generates GHC Haskell FFI bindings from C header files using libclang to get sizes offsets and AST details and emitting C wrapper functions with hashed names to meet C identifier limits. It preserves typedef semantics via generated newtypes and Storeable instances, offers binding specifications in JSON/YAML for prescriptive or compositional reuse, implements a DSL plus type inference for C macros, and produces modules covering pcap of about 156,000 bytes (~4,000 lines).
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:47HS BindGen overview
- 3:13Manual bindings pain points
- 6:29Generated bindings demo
- 8:16Architecture and design
- 9:20C header parsing
- 10:23Naming conventions
- 13:12Customizing bindings
- 16:03Selecting declarations
- 18:15Handling C macros
- 20:42Pcap case study
- 23:11Future plans
- 23:32Q&A
related talks
40m"Fine-Grained C++ Interop"
23mTargeted Static Analysis for OCaml C Stubs: Eliminating gremlins from the code
06mCode Generation: The Lisp Way
26mHot Call-Chain Inlining for the Glasgow Haskell Compiler
25mBinding Syntax for Dependently-Typed Programs
29mAnnotating Deeply Embedded Languages
47mAutomatic C++ source code generation with clang
22mA look across the pond: a comparison between GHC and Racket compilation models
