From 9d14407191448b4ffe02ceb2badf2619c1d28ffb Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Wed, 21 Jun 2023 11:24:12 +0200 Subject: [PATCH] Fix interaction of do-block with ExprWithTySig --- data/15-regressions.blt | 7 +++++++ .../Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/data/15-regressions.blt b/data/15-regressions.blt index 1954c40..289007b 100644 --- a/data/15-regressions.blt +++ b/data/15-regressions.blt @@ -1101,3 +1101,10 @@ func = do } ) anotherArgument + +#test yet another invalid do-block operator alignment +func = do + it "some long description does not matter" $ do + some long function invocation (plus a paren + ed operator expression) + `shouldReturn` all ((==) True) + :: IO () diff --git a/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs b/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs index 4da097b..11fba6c 100644 --- a/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs +++ b/source/library/Language/Haskell/Brittany/Internal/ToBriDoc/Expr.hs @@ -850,7 +850,11 @@ layoutExpr lexpr@(L _ expr) = do ExprWithTySig _ exp1 (HsWC _ typ1) -> do expDoc <- shareDoc $ callLayouter layout_expr exp1 typDoc <- shareDoc $ callLayouter layout_sigType typ1 - docSeq [appSep expDoc, appSep $ docLit $ Text.pack "::", typDoc] + docAlt + [ docForceSingleline + $ docSeq [appSep expDoc, appSep $ docLitS "::", typDoc] + , docPar expDoc (docSeq [docLitS "::", docSeparator, typDoc]) + ] ArithSeq _ Nothing info -> case info of From e1 -> do e1Doc <- shareDoc $ layoutExpr e1