POSTED ON FEBRUARY 5, 2021 TO DEVINFRA, OPEN SOURCE
Open-sourcing Thrift for Haskell
By Noam Zilberstein, Simon Marlow
What it is:
Thrift is a serialization and remote procedure call (RPC) framework used for cross-service communication. Most services at Facebook communicate via Thrift because it provides a simple, language-agnostic protocol for communicating with structured data. Thrift can already be used in programming languages such as C++, Python, and Java using fbthrift. We are also open-sourcing Thrift support for Haskell (hsthrift).
The hsthrift package includes the full collection of tools and libraries for using Thrift in your own Haskell projects. The Haskell Thrift compiler generates the Haskell code needed to communicate with other Thrift services, and the included libraries allow you to build both Thrift clients and servers in Haskell. Haskell Thrift is fully compatible with all other fbthrift languages, so your Haskell project can freely communicate with other services no matter what language they are implemented in!
What it does:
In addition to the standard Thrift tooling suite for cross-service communication, the Haskell Thrift toolchain also supports more advanced functionality, including: 
Required symbols: The Haskell Thrift compiler has the ability to prune the generated code prior to type checking in order to remove unused symbols. The required symbols can be either manually specified or automatically inferred.
Exactprint: Inspired by ghc-exactprint, we also have an exactprint library for Thrift that allows you to perform transformations on the Thrift abstract syntax tree (AST) while preserving the code’s original formatting. Because of the compiler’s correct-by-construction design, any transformations on the type checked AST are guaranteed to be well typed.
Typechecker plugins: The Haskell Thrift compiler has a mechanism to specify type checking plugins that allow you to tailor the type checking rules to the target language. This makes it easy to build new back ends for the compiler.
Splicing: You can splice additional typeclass instances into the generated code to avoid creating orphan instances in other files.
Why it matters:
Practical distributed systems require efficient, type-safe, language-independent RPC support. Thrift is a battle-tested solution to these problems, and hsthrift builds on the efficient foundation of fbthrift to provide Thrift support for Haskell projects. Use it to build efficient distributed systems in Haskell or to incorporate Haskell clients and servers into an existing Thrift-based system.
The Haskell Thrift compiler is also the subject of a recent paper about using advanced features of Haskell’s type system to eliminate bugs in production. Now that the code is open source, other Haskell developers can benefit from real examples of how we have used these techniques to great effect at Facebook.
Get it on GitHub:
Hsthrift 
TAGS:      OPEN SOURCE IN BRIEF
Prev
How machine learning powers Facebook’s News Feed ranking algorithm
Next
Minesweeper automates root cause analysis as a first-line defense against bugs
Read More in Open SourceView All
SEP 29, 2021
Open-sourcing Mariana Trench: Analyzing Android and Java app security in depth
SEP 2, 2021
CacheLib, Facebook’s open source caching engine for web-scale services
AUG 11, 2021
Open-sourcing a more precise time appliance
AUG 4, 2021
Open sourcing Winterfell: A STARK prover and verifier
JUL 15, 2021
Fully Sharded Data Parallel: faster AI training with fewer GPUs
JUN 21, 2021
Meet Kats — a one-stop shop for time series analysis
Related Posts
Jul 06, 2020
Retrie: Haskell refactoring made easy
Oct 08, 2020
CG/SQL: Easy, accurate code generation for SQLite
Oct 24, 2019
Simon Marlow, Simon Peyton Jones, and Satnam Singh win Most Influential ICFP Paper Award
Related Positions
Software Engineer, University Grad
LONDON, UNITED KINGDOM
Research Scientist - Perception and Pixel Quality
REDMOND, US
Audio Research Software Engineer
REDMOND, US
Cellular Standards Engineer
SUNNYVALE, US
Cellular Standards Engineer
REDMOND, US
See All Jobs
Facebook © 2021
About​Careers​Privacy​Cookies​Terms​Help
To help personalize content, tailor and measure ads, and provide a safer experience, we use cookies. By clicking or navigating the site, you agree to allow our collection of information on and off Facebook through cookies. Learn more, including about available controls: Cookies Policy
Facebook EngineeringOpen SourceFacebook Open SourceAndroidiOSWebCore DataData InfrastructureDevInfraProduction EngineeringSecurityConnectivityData Center EngineeringNetworking & TrafficVideo EngineeringVirtual RealityResearch PublicationsML ApplicationsAI ResearchResearch PublicationsWatch Videos