Thrift comes to Haskell
Thrift is a serialization and RPC framework used for cross-service communication, and it powers most service-to-service traffic at Facebook. The fbthrift stack already supports C++, Python, and Java; now Facebook is open-sourcing hsthrift, a complete Thrift toolchain for Haskell.
Hsthrift ships with a compiler that generates Haskell bindings from Thrift IDL files, plus libraries for building both Thrift clients and servers. Because the generated code is fully compatible with other fbthrift languages, Haskell services can interoperate with any existing Thrift-based system regardless of the implementation language on the other end.
Beyond basic RPC
The Haskell toolchain extends the standard Thrift feature set with several capabilities aimed at production-grade code generation:
- Required symbols: The compiler can prune generated code before type checking to eliminate unused symbols. Pruning targets can be specified manually or inferred automatically.
- Exactprint: Modeled after ghc-exactprint, this library supports transformations on the Thrift abstract syntax tree while preserving original formatting. Since the pipeline is correct-by-construction, any transformation applied to the type-checked AST is guaranteed to be well typed.
- Typechecker plugins: A plugin mechanism lets you customize type checking rules for a target language, which simplifies building new compiler back ends.
- Splicing: Additional typeclass instances can be spliced directly into generated code, avoiding orphan instances in separate files.
Why it matters
Distributed systems need efficient, type-safe, language-neutral RPC, and Thrift has proven itself at scale. Hsthrift brings that foundation to Haskell, letting teams build new Haskell services or drop Haskell clients and servers into an existing Thrift-based architecture.
The Haskell Thrift compiler is also the subject of a recent paper on using advanced Haskell type system features to eliminate bugs in production. With the open-source release, developers outside Facebook can study real-world applications of those techniques.
The full source is available on GitHub.



