In this tutorial, we showcase the automatic generation of Haskell bindings with
hs-bindgen on selected libraries:
libpcap is an interface to various kernel packet capture mechanisms. We
present two methods to generate Haskell bindings and use the generated bindings
to print the list of network devices available on the local machine. The
tutorial on pcap is available in the hs-pcap sub-folder of this
repository.
wlroots is a modular Wayland compositor library. The wlroots project is
more complex than libpcap and depends on non-system libraries such as
Wayland and Pixman. Therefore, we split the generation of Haskell
bindings into several library components. We use external binding specifications
to inform higher-level library components about types defined in lower-level
library components. The tutorial on wlroots is available in the hs-wlroots
sub-folder of this repository.
Note
In both cases we use the Nix package manager to manage installation of
hs-bindgen and other system dependencies.
Important
Last update: January 13, 2026. The upstream Nix Flake may have received updates in the meantime.