Two types of Haskell extensions

Daniel Díaz Carrete
1 min readFeb 25, 2021

Many Haskell language extensions have the pleasant property that they merely enable new features of the language, without their presence ever invalidating previously existing code.

For example MultiParamTypeClasses. You can slap it to any .hs file and the file will compile and work exactly as before.

A newer extension that has this property is QualifiedDo. Adding it won’t affect any existing code in a module. You now simply can choose to use different forms of do on a case-by-case basis.

A frequently used extension that lacks this property is OverloadedStrings. Adding it to a module can make previously unambiguous code fail to compile. This is the reason I would prefer for it not to be added to a GHC202X set of “enabled by default” extensions.

The StrictData extension very much doesn’t have this property, because it actually inverts the meaning of some syntax!

Annoyingly, LinearTypes has the corner case that the meaning of the arrows in datatypes defined using GADTSyntax changes when the extension is added.

The upcoming RecordDotSyntax extension has the corner case that, when enabled, record update syntax ceases to allow type-changing updates. Splitting it into two extensions would allow using a non-conflicting subset of its functionality.

--

--