Skip to content

Commit bf8426b

Browse files
authored
[Chapter 3] Clean up indentation section (#448)
1 parent 0ef208d commit bf8426b

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

text/chapter3.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Could not match type Int with type String
173173

174174
PureScript code is _indentation-sensitive_, just like Haskell, but unlike JavaScript. This means that the whitespace in your code is not meaningless, but rather is used to group regions of code, just like curly braces in C-like languages.
175175

176-
If a declaration spans multiple lines, then any lines except the first must be indented past the indentation level of the first line.
176+
If a declaration spans multiple lines, any lines except the first must be indented past the indentation level of the first line.
177177

178178
Therefore, the following is a valid PureScript code:
179179

@@ -209,18 +209,29 @@ But this is not:
209209
… ^D
210210
```
211211

212-
Certain PureScript keywords (such as `where`, `of` and `let`) introduce a new block of code, in which declarations must be further-indented:
212+
Certain PureScript keywords introduce a new block of code, in which declarations must be further-indented:
213213

214214
```haskell
215-
example x y z = foo + bar
216-
where
215+
example x y z =
216+
let
217217
foo = x * y
218218
bar = y * z
219+
in
220+
foo + bar
219221
```
220222

221-
Note how the declarations for `foo` and `bar` are indented past the declaration of `example`.
223+
This doesn't compile:
224+
225+
```haskell
226+
example x y z =
227+
let
228+
foo = x * y
229+
bar = y * z
230+
in
231+
foo + bar
232+
```
222233

223-
The only exception to this rule is the `where` keyword in the initial `module` declaration at the top of a source file.
234+
If you want to learn more (or encounter any problems), see the [Syntax](https://github.com/purescript/documentation/blob/master/language/Syntax.md#syntax) documentation.
224235

225236
## Defining Our Types
226237

0 commit comments

Comments
 (0)