u/Hjullein r/haskell • Recommends
Automatically statically check if a data type is fully strict or not
I was inspired by a question at the end of the Being lazy without being bloated presentation about the library nothunks, which asked if it was possible to do the same check statically.
I managed to come up with a type class `IsStrict` which will give a type error if there is a non-strict field anywhere, at any depth, in the data structure given, explaining where the non-strict field is.
Here it is in a gist: https://gist.github.com/anka-213/440cfef8c8712f5df747029640cfe170
For example, if one were to ask if `String` is strict, it would give this error:
```
Found lazy field of type Char
• In constructor: :
• In type:…