我正在从流行的book学习Haskell。
ghci> Just ord <*> Nothing
Nothing
当我在ghci中运行时,我得到:
<interactive>:1:6: error:
• Variable not in scope: ord :: a0 -> b
• Perhaps you meant one of these:
‘or’ (imported from Prelude), ‘odd’ (imported from Prelude)
我认为有一个拼写错误,或者是由于作者错误或者Haskell的版本改变了语法。
我的问题是:为什么我variable not in scope
获得Just ord <*> Nothing
?
答案 0 :(得分:6)
A quick search for "ord" on Hoogle显示it lives in the Data.Char
module。 (我不知道它是否总是存在,或者它是否最近才被移动到那里。)因此,您只需要将Data.Char
导入ghci
会话。
ghci> import Data.Char
ghci> Just ord <*> Nothing
Nothing