A Non-allocating Optionin-person
We strongly typed functional programmers pride ourselves on writing robust code, making error conditions explicit through expressive types such as option
and result
. Yet, of course, we also want our code to run fast. These desires – explicit, statically checked error conditions – and performance are sometimes in contention: every function that wants to return a result of type answer option
must use the Some
constructor to build successful results. This causes runtime allocation, which eventually triggers latency-causing garbage collection.
This talk describes the design and implementation challenges of taking advantage of an all-0, or null, value to denote error conditions, all without losing the strongly typed nature of option
. Our new optional type is named or_null
, with constructors This
and Null
. The key step is to distinguish with-null types from no-null types, as explained in this extended abstract. We have a prototype implementation in a branch of the OCaml compiler.
Paper (ocaml2024-paper16.pdf) | 402KiB |
Software Engineer at Jane Street. I believe that clever application of theory can eliminate a great deal of programmer errors – specifically, I think fancy types and functional programming are the future. I completed my PhD in 2016 at University of Pennsylvania working under Stephanie Weirich; my dissertation topic was the integration of dependent types into the Haskell programming language. I am a core contributor to the Glasgow Haskell Compiler (GHC) and Chair of the Board of Directors at the Haskell Foundation. My current work at Jane Street centers around further development of the OCaml language and compiler.
Sat 7 SepDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
09:00 - 10:30 | OCaml compiler features and optimizationsOCaml at Orange 2 Chair(s): Stephen Dolan Jane Street Live stream: https://www.youtube.com/watch?v=OuQqblCxJ2Y | ||
09:00 22mTalk | On the design and implementation of Modular Explicitsin-person OCaml File Attached | ||
09:22 22mTalk | Flambda2 Validatorin-person OCaml File Attached | ||
09:45 22mTalk | A Non-allocating Optionin-person OCaml Richard A. Eisenberg Jane Street File Attached | ||
10:07 22mTalk | Mixed Blocks: Storing More Fields Flatin-person OCaml Nicholas Roberts Jane Street File Attached |