I'm running up against what looks like invalid code generated by Happy. The problem boils down to GHC not inferring a polykinded type signature for a function. Here is an example of this:
{-# Language MagicHash #-}
f x = ()
main = pure (f 1#)
Since GHC is inferring f :: a -> ()
where a :: *
, this fails with
• Couldn't match a lifted type with an unlifted type
When matching the kind of ‘GHC.Prim.Int#’
• In the first argument of ‘f’, namely ‘1#’
In the first argument of ‘pure’, namely ‘(f 1#)’
In the expression: pure (f 1#)
Are there any language pragmas I could just turn on to get this code to compile? I know I could in theory just add type signatures but, as this is code generated by Happy which I'd prefer not to have to manually modify anything.
As hinted at by @dfeuer, this is impossible. In the worst case, GHC would have to look for usages of a given function across the whole project in order to infer the levity of an argument.
This was reported as a bug in Happy and has since been fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With