gpt4 book ai didi

haskell - 不在范围内 : <*>

转载 作者:行者123 更新时间:2023-12-03 15:04:42 25 4
gpt4 key购买 nike

我正在尝试 A Fistful of Monads 中的一些示例Learn you a Haskell 的一章,当我在 GHCi 7.6.3 中运行它们时返回了一些错误:

Prelude> Just (+3) <*> Just 3

<interactive>:2:11: Not in scope: `<*>'

使用 <$> 时出现类似错误.

最佳答案

这些运算符来自 Control.Applicative .您需要 import Control.Applicative或者说:m +Control.Applicativeghci .您可以使用 Hoogle 找出许多标准运算符的来源。 .

从 GHC 7.10 开始,使用 Functor-Applicative-Monad Proposal base 4.8 中实现, <*>现在出现在 Prelude 中,不需要导入。

关于haskell - 不在范围内 : <*>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23451230/

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