It seems that if custom type names partially overlap, using moduleQuoter with the custom types throws a very misleading error
I discovered this while trying to add a modelName type to the inferno-ml Prelude. I first tried:
customTypes :: [CustomType]
customTypes = ["tensor", "model", "modelName", "write"]
As you can see, modelName follows model. Then, I tried adding the following to mlQuoter (i.e moduleQuoter customTypes):
...
loadModel : modelName -> model := ###!loadModelFun###;
This led to the following compile-time exception:
src/Inferno/ML/Module/Prelude.hs:192:13: error:
• Error at line 252 column 3
unexpected 'l'
expecting one of the following:
∙ "module"
∙ end of input
• In the quasi-quotation:
[mlQuoter|
...
The error message misleadingly implies that there is a parse error; however, the problem is that modelName follows model, I assume this leads to some ambiguity. Changing the order of the customTypes to [..., "modelName", "model", ...] resolved the error, although this was very difficult to debug!
It seems that if custom type names partially overlap, using
moduleQuoterwith the custom types throws a very misleading errorI discovered this while trying to add a
modelNametype to theinferno-mlPrelude. I first tried:As you can see,
modelNamefollowsmodel. Then, I tried adding the following tomlQuoter(i.emoduleQuoter customTypes):This led to the following compile-time exception:
The error message misleadingly implies that there is a parse error; however, the problem is that
modelNamefollowsmodel, I assume this leads to some ambiguity. Changing the order of thecustomTypesto[..., "modelName", "model", ...]resolved the error, although this was very difficult to debug!