Please log in to watch this conference skillscast.
Sadly, Haskell records aren’t very good - problems include that field names must be unique and that record updates are not very expressive. A variety of solutions have been proposed over many decades, but none has gained traction. The closest answer Haskell has is the lens library, which famously ups the bar on complexity.
This talk explains how to fix all the pain, and make records a strength of Haskell, without making them harder to use. We show how to encode records and fields in a type class, then use existing Haskell machinery to abstract over multiple field names. This type class has been added to GHC, and is automatically generated for standard Haskell records. Building on that, we provide a convenient syntax through a Haskell preprocessor.
We’ve validated our design with the DAML programming language (based on the GHC compiler) which uses these records as standard. We’re happy to report that users experiences have been very positive.
Record syntax: https://github.com/ndmitchell/record-dot-preprocessor DAML programming language: https://daml.com/
YOU MAY ALSO LIKE:
- Fast XML Parsing with Haskell (SkillsCast recorded in October 2017)
- What's in a Functional Compiler? (in Online Event on 30th July 2020)
- The Secrets of the GHC Garbage Collector (SkillsCast recorded in June 2020)
- Lightning Talk: Making and Testing Code Generators in Haskell (SkillsCast recorded in October 2019)
Fixing Haskell Records
Neil Mitchell is a Haskell programmer who lives in Cambridge with his wife Emily and his son Henry. Neil has a PhD in Computer Science from York University, working on making functional programs shorter, faster and safer. Since then he's worked with F# at Credit Suisse and Haskell/F#/C++ at Standard Chartered and Barclays, taking the lessons of functional programming and applying them in finance.