使用GHC 6.12.1编译以下Haskell程序会产生错误:
{-# LANGUAGE NoImplicitPrelude #-}
module Example where
import Prelude(Integer, fromInteger, (==))
f :: Integer -> Integer
f n
| n == 0 = 0
Run Code Online (Sandbox Code Playgroud)
即:
example.hs:9:6:不在范围内:`>>'
将import语句更改为时,错误消失了:
import Prelude(Integer, fromInteger, (==), (>>))
Run Code Online (Sandbox Code Playgroud)
这是有道理的.然而,我不明白为什么首先出现错误.我的程序似乎没有使用任何Monad,而>>Monad运算符之一.
我不知道这个问题的根本原因,但如果您使用-ddump-rn-trace选项编译代码,您可以看到编译器出于某种原因放入(>>)使用的定义列表中,类似于:
finish Dus [(Nothing, [(314, Integer)]),
(Just [(rdd, f)], [(01D, >>), (01E, fromInteger), (01L, ==)]),
(Nothing, [])]
Run Code Online (Sandbox Code Playgroud)
肯定是GHC 6.12.1中的一个错误
| 归档时间: |
|
| 查看次数: |
1391 次 |
| 最近记录: |