Haskell often lends other programming languages ideas, but what can Haskell learn from other functional programming languages?
In this talk I’ll adapt Clojure’s transients to Haskell, and fix them up along the way with the help of Haskell’s type system features.
Transients are immutable data structures that can be made mutable in O(1), and frozen again in O(1). Unlike with Haskell’s arrays, which support superficially similar freeze and thaw operations, this doesn’t ‘destroy’ the frozen structure.
I’ll show the naive translation, a not-so-dirty trick to make it fast, how to layer a more Haskell-like mutable API on top, then borrow some more improvements from recent work on similar structures in Scala and Clojure.