| Version 2 (modified by john@…, 7 years ago) |
|---|
Nondecreasing Indentation
See ExtensionDescriptionHowto for information on how to write these extension descriptions. Please add any new extensions to the list of HaskellExtensions.
Brief Explanation
Ross says: I think NondecreasingIndentation refers to changing > in the H98 (s9.3) rule
L ({n}:ts) (m:ms) = { : (L ts (n:m:ms)) if n > m
to >=. GHC and Hugs do this if the previous token was "do", i.e. they accept
f = do
x <- readLn
withFoo $ \ y -> do
z <- readLn
print (x+y+z)
but not
g x = case x of
Just y -> case y of
Just z -> z
Common uses of this extension are
-- short-circuiting returns a la imperative languages
foo = do
...
if cond then return () else do
...
...
-- when using the FFI one commonly has a lot of nested alloca-like routines
foo = do
alloca $ \foo -> do
alloca $ \bar -> do
alloca $ \baz -> do
....
References
Pros
- Just a minor adjustment
Cons
- Con
- Con
