Support RecursiveDo/`rec` keyword

pull/75/head
Lennart Spitzner 2017-10-24 00:16:49 +02:00
parent 338beb8eea
commit 26f8cdfb65
2 changed files with 24 additions and 0 deletions

View File

@ -48,3 +48,21 @@ func
) )
-> () -> ()
###############################################################################
## RecursiveDo
#test recursivedo 1
{-# LANGUAGE RecursiveDo #-}
foo = do
rec a <- f b
b <- g a
return (a, b)
#test recursivedo 2
{-# LANGUAGE RecursiveDo #-}
foo = do
rec -- comment
a <- f b
b <- g a
return (a, b)

View File

@ -70,6 +70,12 @@ layoutStmt lstmt@(L _ stmt) = docWrapNode lstmt $ case stmt of
(docLit $ Text.pack "let") (docLit $ Text.pack "let")
(docSetBaseAndIndent $ docLines $ return <$> bindDocs) (docSetBaseAndIndent $ docLines $ return <$> bindDocs)
] ]
RecStmt stmts _ _ _ _ _ _ _ _ _ -> do
docSeq
[ docLit (Text.pack "rec")
, docSeparator
, docSetBaseAndIndent $ docLines $ layoutStmt <$> stmts
]
BodyStmt expr _ _ _ -> do BodyStmt expr _ _ _ -> do
expDoc <- docSharedWrapper layoutExpr expr expDoc <- docSharedWrapper layoutExpr expr
docAddBaseY BrIndentRegular $ expDoc docAddBaseY BrIndentRegular $ expDoc