on master help sign in
Merge pull request #1084 from elm-lang/dev

Merge reporting fix from dev

commit8a2e85d556654dbb6987b1c0b957069b1cadb030 authorEvan Czaplicki <info@elm-lang.org> dateWed 7 Oct 2015, 04:28 (11 years ago) parentc3080d96e1a9e1
1 file changed+12−6
src/Parse/Expression.hs+12−6
src/Parse/Expression.hs+12−6
@@ -2,7 +2,7 @@ module Parse.Expression (term, typeAnnotation, definition, expr) where
22
33import qualified Data.List as List
44import Text.Parsec hiding (newline, spaces)
5−import Text.Parsec.Indent (block, withPos)
5+import qualified Text.Parsec.Indent as Indent
66
77import qualified Parse.Binop as Binop
88import Parse.Helpers
@@ -245,12 +245,18 @@ lambdaExpr =
245245caseExpr :: IParser Source.Expr'
246246caseExpr =
247247 do try (reserved "case")
248− e <- padded expr
248+ exp <- padded expr
249249 reserved "of"
250250 whitespace
251− E.Case e <$> block (do c <- case_ ; whitespace ; return c)
251+ Indent.withPos $
252+ do firstBranch <- branch
253+ branches <-
254+ many $ do
255+ try (whitespace >> Indent.checkIndent)
256+ branch
257+ return $ E.Case exp (firstBranch : branches)
252258 where
253− case_ =
259+ branch =
254260 do p <- Pattern.expr
255261 padded rightArrow
256262 (,) p <$> expr
@@ -263,7 +269,7 @@ letExpr =
263269 do try (reserved "let")
264270 whitespace
265271 defs <-
266− block $
272+ Indent.block $
267273 do def <- typeAnnotation <|> definition
268274 whitespace
269275 return def
@@ -288,7 +294,7 @@ typeAnnotation =
288294definition :: IParser Source.Def
289295definition =
290296 addLocation $
291− withPos $
297+ Indent.withPos $
292298 do (name, args) <- defStart
293299 padded equals
294300 body <- expr