在PrimOps中可以使用GHCi吗?以下内容不起作用:
$ ghci -XMagicHash
GHCi, version 8.10.1: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/stefan/.ghci
λ> let x = 42.0# :: Float#
<interactive>:1:18: error:
Not in scope: type constructor or class ‘Float#’
Perhaps you meant ‘Float’ (imported from Prelude)手动导入Prelude不会解决此错误。
更新:导入GHC.Exts后,将显示以下错误:
$ ghci -XMagicHash
GHCi, version 8.10.1: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/stefan/.ghci
λ> import GHC.Exts
λ> let x = 42.0# :: Float#
<interactive>:1:1: error:
GHCi can't bind a variable of unlifted type: x :: Float#发布于 2020-06-28 16:04:17
MagicHash扩展使在名称中使用#成为合法。如果要指定像Float#这样的类型,仍然需要导入它们。执行import GHC.Exts并再试一次。
而且,您不能将它们绑定到let。您需要立即使用它们并重新包装它们。
https://stackoverflow.com/questions/62619602
复制相似问题