1
GHCi告訴我,類型A
不是類型A
。爲什麼?與作用域打交道時,下面是清楚地表明瞭這縮短會議類型A不等於Haskell(ghci解釋器)中的類型A?
>>> data A = A
>>> let x = A
>>> let id A = A
>>>
>>> data A = A
>>> let x' = A
>>> let id' A = A
>>>
>>> data A = A
>>>
>>> let y = id' x
<interactive>:18:13:
Couldn't match expected type `main::Interactive.A'
with actual type `main::Interactive.A'
In the first argument of id', namely `x'
In the expression: id' x
In an equation for `y': y = id' x
您的第二個代碼片段看起來僞造。 – Dog 2013-04-07 17:57:07
這不是真正的奇怪的範圍行爲。它與變量的行爲完全相同,也是唯一有意義的選擇,因爲第二個聲明可能與第一個聲明不兼容。問題是它們在錯誤消息中看起來相同。 – hammar 2013-04-07 17:57:18
對不起,我忘了' – jozefg 2013-04-07 17:58:53