Template Haskell apostrophes and Magic Hash inferrence
Motivation
When using template haskell, one can use ''TypeName
to name a type as a value. In some cases, a magic value with a magic hash (such as SmallArray#
from GHC.Prim) may want to be used in this case. When ''SmallArray#
is written, mistakenly not enabling MagicHash results in some confusing errors:
/path/to/file.hs:72:12: error:
• Not in scope: type constructor or class ‘SmallArray’
Perhaps you meant ‘SmallArray#’ (imported from GHC.Prim)
• In the Template Haskell quotation ''SmallArray
|
72 | , (''SmallArray#, Just [Strict])
| ^^^^^^^^^^^^
/path/to/file.hs:72:12: error:
A section must be enclosed in parentheses thus: (''SmallArray #)
|
72 | , (''SmallArray#, Just [Strict])
| ^^^^^^^^^^^^^
Progress 1/2
Proposal
Ideally when presented like a scenario like this, GHC should recommend enabling the MagicHash extension, instead of these two suggestions which are both not useful here.