gpt4 book ai didi

haskell - 仍然对 GHCi 中的 'let' 感到困惑

转载 作者:行者123 更新时间:2023-12-02 03:32:42 26 4
gpt4 key购买 nike

我已阅读 this question 中的答案,但我还是很困惑。在 Windows 10 中运行的 GHCi(版本 8.2.1)和 WinGHCi(版本 1.0.6)中,我似乎能够在提示符下键入时将值绑定(bind)到表达式,无论是否使用 let (请参阅以下)。同样,我似乎能够通过 let f x = xx* 和 f x = xx*

定义相同执行的函数
Prelude> x = 3
Prelude> let y = 3
Prelude> x
3
Prelude> y
3
Prelude> x == y
True
Prelude>

那么在 GHCi 中,什么时候 let 是必要的

如果相关的话,为 GHCi 设置的语言标志(我认为是默认值,因为我没有弄乱它们)是

base language is: Haskell2010
with the following modifiers:
-XNoDatatypeContexts
-XExtendedDefaultRules
-XNoMonomorphismRestriction
-XNondecreasingIndentation

最佳答案

回答我自己的问题。我刚刚读了脚注

This has changed as of the release of GHC 8.0.1; using let in declarations in GHCi is no longer necessary. As we assume most readers of this edition will be using an earlier version of GHC, we have kept the let notation throughout the book, and this shouldn’t cause any errors or breakage.

Haskell 编程从第一原则中,这证实了 let 不再是必要的。

关于haskell - 仍然对 GHCi 中的 'let' 感到困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51344580/

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