GHC cannot breed a forked species

I am running into what looks like invalid code generated by Happy. The problem comes down to the fact that GHC does not deduce the polykinded type signature for the function. Here's an example of this:

{-# Language MagicHash #-}

f x = ()

main = pure (f 1#)

      

Since GHC outputs 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 include to get this code to compile? I know that in theory I could just add the type signatures, but since this is Happy generated code I would rather not modify it manually.

+3


source to share


1 answer


As @dfeuer hinted, this is not possible. In the worst case, the GHC will have to look for applications of the given function throughout the project to infer the lightness of the argument.



This was reported as a bug in Happy and has been fixed since then .

+1


source







All Articles