1

Consider the following code:

foo = do
  let bar = do
    baz
  bar

It doesn't parse in ghc, version 8. It complains about the line containing baz. This code does parse, though:

foo = do
  let bar = do
      baz
  bar

I find this confusing. What's the essential difference between the two versions?

4

1 回答 1

4

baz问题是在无人区的缩进。它的缩进不够远,不能成为let表达式的一部分,但它缩进得太远,不能成为do包含表达式的表达式的下一部分let

于 2017-02-06T18:15:14.113 回答