{"id":258,"date":"2021-02-07T23:20:57","date_gmt":"2021-02-07T23:20:57","guid":{"rendered":"https:\/\/fde.cat\/?p=258"},"modified":"2021-02-07T23:20:57","modified_gmt":"2021-02-07T23:20:57","slug":"open-sourcing-thrift-for-haskell","status":"publish","type":"post","link":"https:\/\/fde.cat\/index.php\/2021\/02\/07\/open-sourcing-thrift-for-haskell\/","title":{"rendered":"Open-sourcing Thrift for Haskell"},"content":{"rendered":"<h2><span>What it is:<\/span><\/h2>\n<p><a href=\"https:\/\/thrift.apache.org\/static\/files\/thrift-20070401.pdf\"><span>Thrift<\/span><\/a><span> 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 <\/span><a href=\"https:\/\/github.com\/facebook\/fbthrift\"><span>fbthrift<\/span><\/a><span>. We are also open-sourcing Thrift support for Haskell (<\/span><a href=\"https:\/\/github.com\/facebookincubator\/hsthrift\"><span>hsthrift<\/span><\/a><span>).<\/span><\/p>\n<p><span>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!<\/span><\/p>\n<h2><span>What it does:<\/span><\/h2>\n<p><span>In addition to the standard Thrift tooling suite for cross-service communication, the Haskell Thrift toolchain also supports more advanced functionality, including:&nbsp;<\/span><\/p>\n<ul>\n<li><b>Required symbols:<\/b><span> 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.<\/span><\/li>\n<\/ul>\n<ul>\n<li><b>Exactprint:<\/b><span> Inspired by <\/span><a href=\"https:\/\/hackage.haskell.org\/package\/ghc-exactprint\"><span>ghc-exactprint<\/span><\/a><span>, 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\u2019s original formatting. Because of the compiler\u2019s correct-by-construction design, any transformations on the type checked AST are guaranteed to be well typed.<\/span><\/li>\n<\/ul>\n<ul>\n<li><b>Typechecker plugins: <\/b><span>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.<\/span><\/li>\n<\/ul>\n<ul>\n<li><b>Splicing: <\/b><span>You can splice additional typeclass instances into the generated code to avoid creating orphan instances in other files.<\/span><\/li>\n<\/ul>\n<h2><span>Why it matters:<\/span><\/h2>\n<p><span>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.<\/span><\/p>\n<p><span>The Haskell Thrift compiler is also the subject of a recent <\/span><a href=\"https:\/\/dl.acm.org\/doi\/10.1145\/3406088.3409020\"><span>paper<\/span><\/a><span> about using advanced features of Haskell\u2019s 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.<\/span><\/p>\n<h2><span>Get it on GitHub:<\/span><\/h2>\n<p><a href=\"https:\/\/github.com\/facebookincubator\/hsthrift\"><span>Hsthrift<\/span><\/a><span>&nbsp;<\/span><\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/engineering.fb.com\/2021\/02\/05\/open-source\/hsthrift\/\">Open-sourcing Thrift for Haskell<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/engineering.fb.com\/\">Facebook Engineering<\/a>.<\/p>\n<p><a href=\"https:\/\/engineering.fb.com\/2021\/02\/05\/open-source\/hsthrift\/\" target=\"_blank\" rel=\"noopener\">Read More<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&hellip; <a class=\"more-link\" href=\"https:\/\/fde.cat\/index.php\/2021\/02\/07\/open-sourcing-thrift-for-haskell\/\">Continue reading <span class=\"screen-reader-text\">Open-sourcing Thrift for Haskell<\/span><\/a><\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[1,7],"tags":[15],"class_list":["post-258","post","type-post","status-publish","format-standard","hentry","category-external","category-technology","tag-facebook","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":166,"url":"https:\/\/fde.cat\/index.php\/2020\/12\/30\/2020-year-in-review-connectivity-innovations-faster-apps-and-progress-toward-net-zero\/","url_meta":{"origin":258,"position":0},"title":"2020 year in review: Connectivity innovations, faster apps, and progress toward net zero","date":"December 30, 2020","format":false,"excerpt":"It goes without saying that 2020 has been a challenging year, to put it lightly. But if anything, the COVID-19 pandemic has shined a light on our need to connect as people. For Facebook, that meant our work has become more important than ever. Whether it was finding new and\u2026","rel":"","context":"In &quot;External&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":649,"url":"https:\/\/fde.cat\/index.php\/2022\/11\/09\/tulip-schematizing-metas-data-platform\/","url_meta":{"origin":258,"position":1},"title":"Tulip: Schematizing Meta\u2019s data platform","date":"November 9, 2022","format":false,"excerpt":"We\u2019re sharing Tulip, a binary serialization protocol supporting schema evolution.\u00a0 Tulip assists with data schematization by addressing protocol reliability and other issues simultaneously.\u00a0 It replaces multiple legacy formats used in Meta\u2019s data platform and has achieved significant performance and efficiency gains. There are numerous heterogeneous services, such as warehouse data\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":614,"url":"https:\/\/fde.cat\/index.php\/2022\/07\/27\/programming-languages-endorsed-for-server-side-use-at-meta\/","url_meta":{"origin":258,"position":2},"title":"Programming languages endorsed for server-side use at Meta","date":"July 27, 2022","format":false,"excerpt":"\u2013 Supporting a programming language at Meta is a very careful and deliberate decision. \u2013 We\u2019re sharing our internal programming language guidance that helps our engineers and developers choose the best language for their projects. \u2013 Rust is the latest addition to Meta\u2019s list of supported server-side languages. At Meta,\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":302,"url":"https:\/\/fde.cat\/index.php\/2021\/08\/31\/a-brief-history-of-rust-at-facebook\/","url_meta":{"origin":258,"position":3},"title":"A brief history of Rust at Facebook","date":"August 31, 2021","format":false,"excerpt":"Facebook is embracing Rust, one of the most loved and fastest-growing programming languages available today. In addition to bringing new talent to its Rust team, Facebook has announced that it is officially joining the nonprofit Rust Foundation. Alongside fellow members including Mozilla (the creators of Rust), AWS, Microsoft, and Google,\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":776,"url":"https:\/\/fde.cat\/index.php\/2023\/10\/23\/5-things-you-didnt-know-about-buck2\/","url_meta":{"origin":258,"position":4},"title":"5 Things you didn\u2019t know about Buck2","date":"October 23, 2023","format":false,"excerpt":"Meta has a very large monorepo, with many\u00a0 different programming languages. To optimize build and performance, we developed our own build system called Buck, which was first open-sourced in 2013.\u00a0 Buck2 is the recently open-sourced successor. In our internal tests at Meta, we observed that Buck2 completed builds approximately 2x\u2026","rel":"","context":"In &quot;Technology&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":169,"url":"https:\/\/fde.cat\/index.php\/2020\/12\/16\/co-experiences-hanging-out-in-the-digital-living-room\/","url_meta":{"origin":258,"position":5},"title":"Co-experiences: Hanging out in the digital living room","date":"December 16, 2020","format":false,"excerpt":"In the spring of 2019 \u2014\u00a0a full year before the COVID-19 pandemic caused the entire world to turn our living rooms into offices, schools, and gathering places \u2014\u00a0Mark Zuckerberg shared a plan to create the digital equivalent of the living room, where people could connect and hang out together. That\u2026","rel":"","context":"In &quot;External&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/posts\/258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/comments?post=258"}],"version-history":[{"count":2,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/posts\/258\/revisions"}],"predecessor-version":[{"id":260,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/posts\/258\/revisions\/260"}],"wp:attachment":[{"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/media?parent=258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/categories?post=258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fde.cat\/index.php\/wp-json\/wp\/v2\/tags?post=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}