Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 为什么不是';哈斯克尔的缩进不正确吗?_Haskell - Fatal编程技术网

Haskell 为什么不是';哈斯克尔的缩进不正确吗?

Haskell 为什么不是';哈斯克尔的缩进不正确吗?,haskell,Haskell,为什么第5行不包含缩进错误。我希望在编译时得到一个解析错误。我希望第5行的+必须与第4行的*对齐 module Learn where x = 10 * 5 + y -- why isn't this incorrect indentation myResult = x * 5 y = 10 它编译,因为没有块要考虑。 缩进仅在where,let,do,的情况下起作用。 这些关键字开始一块东西,了解一行是继续上一个条目、开始新条目还是结束该块很重要 case f 5 of

为什么第5行不包含缩进错误。我希望在编译时得到一个解析错误。我希望第5行的
+
必须与第4行的
*
对齐

module Learn where

x = 10
  * 5
 + y  -- why isn't this incorrect indentation

myResult = x * 5

y = 10

它编译,因为没有块要考虑。

缩进仅在
where
let
do
的情况下起作用。
这些关键字开始一块东西,了解一行是继续上一个条目、开始新条目还是结束该块很重要

case f 5 of
   A -> foo
      32         -- continues the previous entry
   B -> 12       -- starts a new entry
+ bar 43         -- ends the case

=
之后,我们不需要将块拆分为条目:只有一个表达式。因此没有应用。

它编译,因为没有块要考虑。

缩进仅在
where
let
do
的情况下起作用。
这些关键字开始一块东西,了解一行是继续上一个条目、开始新条目还是结束该块很重要

case f 5 of
   A -> foo
      32         -- continues the previous entry
   B -> 12       -- starts a new entry
+ bar 43         -- ends the case

=
之后,我们不需要将块拆分为条目:只有一个表达式。因此不适用。

这是因为
x
的定义都在
x
开头的右边。每行的起始位置并不重要,只要这些行缩进到
x

的右边,这就可以编译了,因为
x
的定义都在
x
开头的右边。只要这些行缩进到
x
的右侧,每行的起始位置就不重要了