Ale*_*lec 5 haskell types happy polykinds
我遇到了由 Happy 生成的看似无效的代码。问题归结为 GHC 没有推断函数的多类类型签名。下面是一个例子:
\n\n{-# Language MagicHash #-}\n\nf x = ()\n\nmain = pure (f 1#)\nRun Code Online (Sandbox Code Playgroud)\n\n由于 GHC 正在推断f :: a -> ()哪里a :: *,所以失败了
\xe2\x80\xa2 Couldn't match a lifted type with an unlifted type\n When matching the kind of \xe2\x80\x98GHC.Prim.Int#\xe2\x80\x99\n \xe2\x80\xa2 In the first argument of \xe2\x80\x98f\xe2\x80\x99, namely \xe2\x80\x981#\xe2\x80\x99\n In the first argument of \xe2\x80\x98pure\xe2\x80\x99, namely \xe2\x80\x98(f 1#)\xe2\x80\x99\n In the expression: pure (f 1#)\nRun Code Online (Sandbox Code Playgroud)\n\n是否有任何语言编译指示我可以打开来编译此代码?我知道理论上我可以只添加类型签名,但是,由于这是由 Happy 生成的代码,我不希望手动修改任何内容。
\n