Open-sourcing Thrift for Haskell

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, …

Noam Zilberstein
3 min readintermediate
--
View Original

Overview

The article discusses the open-sourcing of Thrift support for Haskell, a serialization and remote procedure call (RPC) framework used for cross-service communication. It highlights the features of the hsthrift package, which includes tools and libraries for building Thrift clients and servers in Haskell, and emphasizes its compatibility with other fbthrift languages.

What You'll Learn

1

How to use Thrift in Haskell projects for cross-service communication

2

Why Thrift is a suitable choice for building efficient distributed systems

3

When to utilize advanced features of Haskell's type system with Thrift

Key Questions Answered

What is Thrift and how is it used at Facebook?
Thrift is a serialization and remote procedure call (RPC) framework that facilitates cross-service communication at Facebook. It allows services to communicate using a simple, language-agnostic protocol, and is utilized across various programming languages including C++, Python, and Java.
What features does the Haskell Thrift toolchain provide?
The Haskell Thrift toolchain includes features such as required symbols pruning, exactprint for preserving code formatting during transformations, typechecker plugins for custom rules, and splicing additional typeclass instances into generated code. These features enhance the usability and flexibility of Thrift in Haskell projects.
Why is the Haskell Thrift compiler significant for developers?
The Haskell Thrift compiler is significant because it leverages advanced features of Haskell's type system to improve type safety and eliminate bugs in production. This open-source release allows other Haskell developers to learn from Facebook's implementation and apply similar techniques in their projects.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Rpc Framework
Thrift
Used for serialization and remote procedure calls in cross-service communication.
Programming Language
Haskell
The language in which the Thrift support is being open-sourced.

Key Actionable Insights

1
Utilize the Haskell Thrift compiler to enhance type safety in your projects.
By leveraging the advanced type system features of Haskell, developers can reduce the likelihood of bugs in production systems, making their applications more robust.
2
Incorporate Thrift into your Haskell applications for seamless communication with services in other languages.
This interoperability allows for greater flexibility in service architecture, enabling teams to choose the best language for each service while maintaining effective communication.
3
Explore the exactprint library to maintain code formatting during transformations.
This feature is particularly useful when modifying Thrift abstract syntax trees, as it ensures that the original code style is preserved, making it easier to read and maintain.

Common Pitfalls

1
Failing to specify required symbols can lead to bloated generated code.
It's important to utilize the pruning feature of the Haskell Thrift compiler to keep the codebase clean and maintainable by removing unused symbols.