Indentation works differently for multi-way if than for guards when using comma-separate view patterns
When trying to parse the following piece of code:
{-# LANGUAGE MultiWayIf #-}
module Test where
data AB = A | B
aAndB :: AB -> AB -> Bool
aAndB ab1 ab2 =
if | A <- ab1
, B <- ab2 -> True
| otherwise -> False
I get the following error
test.hs:9:6: error:
parse error (possibly incorrect indentation or mismatched brackets)
This is as currently is inconsistent with how guards are parsed, e.g.:
aAndB2 :: AB -> AB -> Bool
aAndB2 ab1 ab2 | A <- ab1
, B <- ab2 = True
| otherwise = False
works perfectly fine.
Note, that if I indent the comma a bit in aAndB, the following will parse correctly:
aAndB :: AB -> AB -> Bool
aAndB ab1 ab2 =
if | A <- ab1
, B <- ab2 -> True
| otherwise -> False
Of course, this is far from a major issue, but I thought it would probably be beneficial to report the issue nonetheless. It also looks likely less neat with the comma indented.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | lowest |
Resolution | Unresolved |
Component | Compiler (Parser) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |