gpt4 book ai didi

haskell - 为什么 Just ord <*> Nothing 得到 'variable not in scope'?

转载 作者:行者123 更新时间:2023-12-02 08:10:12 25 4
gpt4 key购买 nike

我正在从一个流行的 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 ?

最佳答案

A quick search for "ord" on Hoogle显示 it lives in the Data.Char module . (我不知道它是一直在那里,还是最近才移到那里。)所以你只需要将 Data.Char 导入你的 ghci session 。

ghci> import Data.Char
ghci> Just ord <*> Nothing
Nothing

关于haskell - 为什么 Just ord <*> Nothing 得到 'variable not in scope'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47949048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com