Skip to content

Allow annotating fields to be lazy even if the module is not using StrictData

This comes up when using Template Haskell.

There is no convenient way to say that the field of data field in generated declaration to be explicitly lazy.

The current go to approach is to query whether StrictData extension is enabled and then generate data Foo = Foo ~Int ~Char or data = Foo Int Char based on that.

Or maybe library functions like normalC or sourceLazy should query whether StrictData is enabled and just work.


Note, that for terms, one can ask people to enable BangPatterns so one could generate explicitly banged code like, let !foo = 2 + 2 in ..., but there is no extensions to just enable writing data Foo = Foo ~Int ~Char without also changing the meaning of data Foo = Foo Int Char, i.e. there is no LazyDataAnnotations. In my opinion that is design flaw in StrictData extension: it bundles syntax and changes defaults.

Edited by Oleg Grenrus
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information