This post is one for the Google spider so that if somebody else has this problem they can find the solution by searching (I haven’t found mention of it anywhere else on the web).
If you are using HStringTemplate (version 0.6.3 at least) in Haskell and your program is failing at runtime with the not-particularly-informative message
"constrFields", you might wonder what the problem is. This message is generated by the SYB library used in the implementation of
Text.StringTemplate.GenericStandard. The error is caused by attempting to access a constructor for a primitive type.
Why is HStringTemplate doing this? Looking at the HStringTemplate source we can see that it does not currently support generation of generic
ToSElem instances for records that have fields of type
Char. At the moment, the simplest solution to this problem is to change your
Char fields into