为什么我为Just ord< *>获得'变量不在范围内'?什么?

时间:2017-12-23 01:34:57

标签: haskell

我正在从流行的book学习Haskell。

它包含following ghci command

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

1 个答案:

答案 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