Please log in to watch this conference skillscast.
Newtypes are the key to data abstraction in Haskell, and come with an crucial performance guarantee: it doesn’t cost anything to use a newtype.
Embarrassingly, this guarantee is weak: it fails as soon as you embed a newtype’d value in a data structure. At the same time, the hugely-popular language feature “generalised newtype deriving” turns out to rely internally on a strong version of the guarantee. And, in the presence of type-level functions, the strong version of the guarantee turns out to be unsound, leading to a notorious type-soundness bug in GHC that has persisted for several years.
As is often the case in Haskell, finding a solid, principled solution to the problem turned out to be far more interesting than we expected, requiring us to distinguish two flavours of type equality (representational and nominal), with a “role system” to allow type-safe abstraction. I think the result is pretty cool. In this talk I’ll explain what all the fuss is about.
YOU MAY ALSO LIKE:
- Well-Typed's Fast Track to Haskell (in London on 10th - 11th October 2017)
- HaskellX2gether Community Weekend (in London on 14th - 15th October 2017)
- Well-Typed's Guide to Haskell Performance and Optimization (in London on 16th - 17th October 2017)
- Well-Typed's Guide to the Haskell Type System (in London on 18th October 2017)
Safe, Zero-Cost Coercions in Haskell
Simon Peyton Jones, MA, MBCS, CEng, graduated from Trinity College Cambridge in 1980. Simon was a key contributor to the design of the now-standard functional language Haskell, and is the lead designer of the widely-used Glasgow Haskell Compiler (GHC). He has written two textbooks about the implementation of functional languages.