Haskell/Solutions/Indentation
From Wikibooks, the open-content textbooks collection
| Exercises |
|---|
| In one word, what happens if you see something indented MORE? |
Nothing! The part that is indented more is a subexpression of the part that is indented less.
| Exercises |
|---|
Translate the following layout into curly braces and semicolons. Note: to underscore the mechanical nature of this process, we deliberately chose something which is probably not valid Haskell:
of a
b
c
d
where
a
b
c
do
you
like
the
way
i let myself
abuse
these
layout rules
|
At the moment of writing, I refuse!
| Exercises |
|---|
The if-within-do problem has tripped up so many Haskellers, that one programmer has posted a proposal to the Haskell prime initiative to add optional semicolons between if then else. How would that fix the problem? |
Then {if expr; then code; else other_code}, or
if expr then code else other_code
becomes legal.