Deriving Via, or, How to Turn Hand-Written Instances into an Anti-Pattern
Baldur Blöndal, Andres Löh, Ryan Scott

Haskell’s deriving construct is a cheap and cheerful way to quickly generate instances of type classes that follow common patterns. But at present, there are only a subset of such type class patterns that deriving supports, and if a particular class lies outside of this subset, then one cannot derive it at all, with no alternative except for laboriously declaring the instances by hand.

To overcome this deficit, we introduce Deriving Via, an extension to deriving that enables programmers to compose instances from named programming patterns, thereby turning deriving into a high-level domain-specific language for defining instances. Deriving Via leverages newtypes – an already familiar tool of the Haskell trade – to declare recurring patterns in a way that both feels natural and allows a high degree of abstraction.

Download / Links
ACM DL Author-ize serviceDeriving via: or, how to turn hand-written instances into an anti-pattern
Baldur Blöndal, Andres Löh, Ryan Scott
Haskell 2018 Proceedings of the 11th ACM SIGPLAN International Symposium on Haskell, 2018
Talk, presented at the Haskell eXchange 2018
Talk, presented at the IFIP WG 2.1 meeting in Brandenburg

Valid XHTML 1.0! Valid CSS!

Andres Löh, 2018-10-26