From 6a97379b330078463cfd89353cf76787ce66a678 Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Tue, 28 Nov 2017 17:56:28 +0100 Subject: [PATCH] Add whitespace around operator in section, Fixes #67 --- src-literatetests/10-tests.blt | 9 ++++----- src-literatetests/15-regressions.blt | 12 ++++++++---- .../Haskell/Brittany/Internal/Layouters/Expr.hs | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src-literatetests/10-tests.blt b/src-literatetests/10-tests.blt index 03b1c6b..e04887c 100644 --- a/src-literatetests/10-tests.blt +++ b/src-literatetests/10-tests.blt @@ -461,17 +461,16 @@ func = lakjsdlajsdljasdlkjasldjasldjasldjalsdjlaskjd lakjsdlajsdljas ### #test left -func = (1+) +func = (1 +) #test right -func = (+1) +func = (+ 1) #test left inf -## TODO: this could be improved.. -func = (1`abc`) +func = (1 `abc`) #test right inf -func = (`abc`1) +func = (`abc` 1) ### #group tuples diff --git a/src-literatetests/15-regressions.blt b/src-literatetests/15-regressions.blt index bea97cc..319713b 100644 --- a/src-literatetests/15-regressions.blt +++ b/src-literatetests/15-regressions.blt @@ -324,17 +324,17 @@ func = fooooooooooooooooooooooooooooooooo + foooooooooooooooooooooooooooooooo parserPrim = [ r | r <- - [ SGPPrimFloat $ bool id (0-) minus $ readGnok "parserPrim" - (d1 ++ d2 ++ d3 ++ d4) + [ SGPPrimFloat $ bool id (0 -) minus $ readGnok "parserPrim" + (d1 ++ d2 ++ d3 ++ d4) | d2 <- string "." , d3 <- many1 (oneOf "0123456789") , _ <- string "f" ] - <|> [ SGPPrimFloat $ bool id (0-) minus $ fromIntegral + <|> [ SGPPrimFloat $ bool id (0 -) minus $ fromIntegral (readGnok "parserPrim" d1 :: Integer) | _ <- string "f" ] - <|> [ SGPPrimInt $ bool id (0-) minus $ fromIntegral + <|> [ SGPPrimInt $ bool id (0 -) minus $ fromIntegral (readGnok "parserPrim" d1 :: Integer) | _ <- string "i" ] @@ -486,3 +486,7 @@ func -> Proxy (str :: [*]) -> m (Tagged str String) +#test issue 67 +fmapuv :: U.Unbox a => (a -> b) -> U.Vector a -> V.Vector b +fmapuv f xs = G.generate (G.length xs) (f . (xs G.!)) + diff --git a/src/Language/Haskell/Brittany/Internal/Layouters/Expr.hs b/src/Language/Haskell/Brittany/Internal/Layouters/Expr.hs index 90fd435..0e36a21 100644 --- a/src/Language/Haskell/Brittany/Internal/Layouters/Expr.hs +++ b/src/Language/Haskell/Brittany/Internal/Layouters/Expr.hs @@ -321,11 +321,11 @@ layoutExpr lexpr@(L _ expr) = docWrapNode lexpr $ case expr of SectionL left op -> do -- TODO: add to testsuite leftDoc <- docSharedWrapper layoutExpr left opDoc <- docSharedWrapper layoutExpr op - docSeq [leftDoc, opDoc] + docSeq [leftDoc, docSeparator, opDoc] SectionR op right -> do -- TODO: add to testsuite opDoc <- docSharedWrapper layoutExpr op rightDoc <- docSharedWrapper layoutExpr right - docSeq [opDoc, rightDoc] + docSeq [opDoc, docSeparator, rightDoc] ExplicitTuple args boxity | Just argExprs <- args `forM` (\case (L _ (Present e)) -> Just e; _ -> Nothing) -> do argDocs <- docSharedWrapper layoutExpr `mapM` argExprs