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:
- DDD eXchange 2017 (in London on 27th - 28th April 2017)
- Greg Young's CQRS, Domain Events, Event Sourcing and how to apply DDD (in Stockholm on 22nd - 24th May 2017)
- Simon Brown's Software Architecture for Developers Workshop (in London on 22nd - 23rd May 2017)
- Whole Team Approach to Agile Testing (in London on 5th - 7th June 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.