From cb3f4787147fa665b2f7f8481850751a408fad9d Mon Sep 17 00:00:00 2001 From: Jaro Date: Fri, 7 Apr 2023 04:39:58 +0200 Subject: [PATCH] Fix style: white space around operators. --- src/Data/Text/ParagraphLayout/Internal/Break.hs | 2 +- .../ParagraphLayout/Internal/LinePagination.hs | 4 ++-- .../Internal/ParagraphConstruction.hs | 2 +- src/Data/Text/ParagraphLayout/Internal/Plain.hs | 4 ++-- .../Text/ParagraphLayout/Internal/ResolvedSpan.hs | 2 +- src/Data/Text/ParagraphLayout/Internal/Run.hs | 2 +- .../Text/ParagraphLayout/Internal/TextContainer.hs | 14 +++++++------- src/Data/Text/ParagraphLayout/Internal/Zipper.hs | 2 +- .../ParagraphLayout/Internal/TextContainerSpec.hs | 2 +- .../Text/ParagraphLayout/Internal/ZipperSpec.hs | 12 ++++++------ test/Data/Text/ParagraphLayoutSpec.hs | 8 ++++---- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Data/Text/ParagraphLayout/Internal/Break.hs b/src/Data/Text/ParagraphLayout/Internal/Break.hs index 943e891..c03285d 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Break.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Break.hs @@ -47,7 +47,7 @@ locale lang lb = Locale $ (clean lang) ++ (lbKeyword lb) -- including case changes and converting hyphens to underscores. -- -- This filter is here just to stop syntactically incorrect input. - clean = takeWhile (`elem` ['A'..'Z'] ++ ['a'..'z'] ++ "_-") + clean = takeWhile (`elem` ['A' .. 'Z'] ++ ['a' .. 'z'] ++ "_-") -- | List of all breaks in the given text, with offsets in descending order, -- including the status of the break if applicable. diff --git a/src/Data/Text/ParagraphLayout/Internal/LinePagination.hs b/src/Data/Text/ParagraphLayout/Internal/LinePagination.hs index 441b7d5..82308f2 100644 --- a/src/Data/Text/ParagraphLayout/Internal/LinePagination.hs +++ b/src/Data/Text/ParagraphLayout/Internal/LinePagination.hs @@ -186,9 +186,9 @@ splitsWithTotal ls = zeroSplit :| splits splitsWithTotal' :: Line a => Int32 -> [a] -> [a] -> [(Int32, ([a], [a]))] splitsWithTotal' _ _ [] = [] -splitsWithTotal' total closed (x:xs) = split : splits +splitsWithTotal' total closed (x : xs) = split : splits where split = (newTotal, (reverse newClosed, xs)) splits = splitsWithTotal' newTotal newClosed xs - newClosed = x:closed + newClosed = x : closed newTotal = total + lineHeight x diff --git a/src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs b/src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs index 3d40771..ca4740e 100644 --- a/src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs +++ b/src/Data/Text/ParagraphLayout/Internal/ParagraphConstruction.hs @@ -34,7 +34,7 @@ infixr 5 >|< (>|<) :: (SpanOptions, String) -> (Lazy.Text, [Span]) -> (Lazy.Text, [Span]) (spanLanguage, spanText) >|< (oldText, oldSpans) = (newText, newSpans) where - newSpans = newSpan:oldSpans + newSpans = newSpan : oldSpans newSpan = Span (lengthWord8 packedSpanText) spanLanguage newText = chunk packedSpanText oldText packedSpanText = pack spanText diff --git a/src/Data/Text/ParagraphLayout/Internal/Plain.hs b/src/Data/Text/ParagraphLayout/Internal/Plain.hs index 5061e29..9b4a3e9 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Plain.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Plain.hs @@ -83,7 +83,7 @@ layoutAndAlignLines maxWidth runs = frags -- is preserved even across runs. canonicalOrder :: [WithSpan PF.ProtoFragment] -> [WithSpan PF.ProtoFragment] canonicalOrder [] = [] -canonicalOrder pfs@((WithSpan _ headPF):_) = case PF.direction headPF of +canonicalOrder pfs@((WithSpan _ headPF) : _) = case PF.direction headPF of -- TODO: Update for bidi. Just DirLTR -> pfs Just DirRTL -> reverse pfs @@ -285,7 +285,7 @@ resolveSpans p@(Paragraph arr pStart spans pOpts) = do let sLengths = map spanLength spans (i, s, sStart, sLen) <- getZipList $ (,,,) - <$> ZipList [0..] + <$> ZipList [0 ..] <*> ZipList spans <*> ZipList sStarts <*> ZipList sLengths diff --git a/src/Data/Text/ParagraphLayout/Internal/ResolvedSpan.hs b/src/Data/Text/ParagraphLayout/Internal/ResolvedSpan.hs index ca5c0df..f6f717c 100644 --- a/src/Data/Text/ParagraphLayout/Internal/ResolvedSpan.hs +++ b/src/Data/Text/ParagraphLayout/Internal/ResolvedSpan.hs @@ -49,7 +49,7 @@ instance SeparableTextContainer a => SeparableTextContainer (WithSpan a) where dropWhileEnd p (WithSpan rs c) = WithSpan rs (dropWhileEnd p c) splitBySpanIndex :: [WithSpan a] -> [[a]] -splitBySpanIndex xs = [getBySpanIndex i xs | i <- [0..]] +splitBySpanIndex xs = [getBySpanIndex i xs | i <- [0 ..]] getBySpanIndex :: Int -> [WithSpan a] -> [a] getBySpanIndex idx xs = map contents $ filter matchingIndex $ xs diff --git a/src/Data/Text/ParagraphLayout/Internal/Run.hs b/src/Data/Text/ParagraphLayout/Internal/Run.hs index 2ec23df..2c8c8ff 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Run.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Run.hs @@ -96,7 +96,7 @@ protoRuns' curZipper curRuns = case considerNext curZipper of Nothing -> curRuns Just choice -> let headRun@(nextZipper, _, _) :| tailRuns = foldRun choice curRuns - in protoRuns' nextZipper (headRun:tailRuns) + in protoRuns' nextZipper (headRun : tailRuns) foldRun :: ZipperChoice -> [ProtoRun] -> NonEmpty ProtoRun diff --git a/src/Data/Text/ParagraphLayout/Internal/TextContainer.hs b/src/Data/Text/ParagraphLayout/Internal/TextContainer.hs index e9d8772..8cbb813 100644 --- a/src/Data/Text/ParagraphLayout/Internal/TextContainer.hs +++ b/src/Data/Text/ParagraphLayout/Internal/TextContainer.hs @@ -71,8 +71,8 @@ splitTextsBy breakFunc tcs = splitTextsBy' :: SeparableTextContainer a => (a -> [Int]) -> [a] -> [a] -> [([a], [a])] splitTextsBy' _ _ [] = [] -splitTextsBy' breakFunc closed (tc:tcs) = - fullSplits ++ splitTextsBy' breakFunc (tc:closed) tcs +splitTextsBy' breakFunc closed (tc : tcs) = + fullSplits ++ splitTextsBy' breakFunc (tc : closed) tcs where fullSplits = map mergeWithRest tcSplits mergeWithRest (x1, x2) = @@ -96,7 +96,7 @@ nonEmptyPair (xs, ys) = case (nonEmpty xs, nonEmpty ys) of collapse :: SeparableTextContainer a => NonEmpty a -> [a] collapse (tc :| tcs) | Text.null (getText tc) = tcs - | otherwise = tc:tcs + | otherwise = tc : tcs -- | Treat a list of text containers as a contiguous sequence, -- and remove a prefix of characters that match the given predicate. @@ -142,17 +142,17 @@ trimTextsEndPreserve p tcs = trimTextsStart' :: SeparableTextContainer a => (Char -> Bool) -> [a] -> [a] trimTextsStart' _ [] = [] -trimTextsStart' p (tc:tcs) +trimTextsStart' p (tc : tcs) | Text.null (getText trimmed) = trimTextsStart' p tcs - | otherwise = trimmed:tcs + | otherwise = trimmed : tcs where trimmed = dropWhileStart p tc trimTextsEnd' :: SeparableTextContainer a => (Char -> Bool) -> [a] -> [a] trimTextsEnd' _ [] = [] -trimTextsEnd' p (tc:tcs) +trimTextsEnd' p (tc : tcs) | Text.null (getText trimmed) = trimTextsEnd' p tcs - | otherwise = reverse $ trimmed:tcs + | otherwise = reverse $ trimmed : tcs where trimmed = dropWhileEnd p tc diff --git a/src/Data/Text/ParagraphLayout/Internal/Zipper.hs b/src/Data/Text/ParagraphLayout/Internal/Zipper.hs index d9baf69..d6f260c 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Zipper.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Zipper.hs @@ -133,4 +133,4 @@ takeWord8 m (Text arr off _) = Text arr off m -- Requires that @m@ be within the bounds of the `Text`, not at the beginning -- or at the end, and not inside a code point. dropWord8 :: Int -> Text -> Text -dropWord8 m (Text arr off len) = Text arr (off+m) (len-m) +dropWord8 m (Text arr off len) = Text arr (off + m) (len - m) diff --git a/test/Data/Text/ParagraphLayout/Internal/TextContainerSpec.hs b/test/Data/Text/ParagraphLayout/Internal/TextContainerSpec.hs index dfb5508..a9555db 100644 --- a/test/Data/Text/ParagraphLayout/Internal/TextContainerSpec.hs +++ b/test/Data/Text/ParagraphLayout/Internal/TextContainerSpec.hs @@ -68,7 +68,7 @@ exampleBreakPoints c = d = cOffset c isSpace :: Char -> Bool -isSpace = (==' ') +isSpace = (== ' ') spec :: Spec spec = do diff --git a/test/Data/Text/ParagraphLayout/Internal/ZipperSpec.hs b/test/Data/Text/ParagraphLayout/Internal/ZipperSpec.hs index 197b215..692e0e6 100644 --- a/test/Data/Text/ParagraphLayout/Internal/ZipperSpec.hs +++ b/test/Data/Text/ParagraphLayout/Internal/ZipperSpec.hs @@ -98,8 +98,8 @@ spec = do Zipper.atEnd z `shouldBe` False it ("preceding text has length " ++ show n) $ do Text.length (Zipper.preceding z) `shouldBe` n - it ("following text has length " ++ show (sampleLength-n)) $ do - Text.length (Zipper.following z) `shouldBe` (sampleLength-n) + it ("following text has length " ++ show (sampleLength - n)) $ do + Text.length (Zipper.following z) `shouldBe` (sampleLength - n) it "recombines into original text" $ do Zipper.recombine z `shouldBe` sampleText @@ -110,10 +110,10 @@ spec = do Zipper.atStart z `shouldBe` False it "is not at end" $ do Zipper.atEnd z `shouldBe` False - it ("preceding text has length " ++ show (n+1)) $ do - Text.length (Zipper.preceding z) `shouldBe` (n+1) - it ("following text has length " ++ show (sampleLength-n-1)) $ do - Text.length (Zipper.following z) `shouldBe` (sampleLength-n-1) + it ("preceding text has length " ++ show (n + 1)) $ do + Text.length (Zipper.preceding z) `shouldBe` (n + 1) + it ("following text has length " ++ show (sampleLength - n - 1)) $ do + Text.length (Zipper.following z) `shouldBe` (sampleLength - n - 1) it "recombines into original text" $ do Zipper.recombine z `shouldBe` sampleText diff --git a/test/Data/Text/ParagraphLayoutSpec.hs b/test/Data/Text/ParagraphLayoutSpec.hs index 5f51dce..7d723df 100644 --- a/test/Data/Text/ParagraphLayoutSpec.hs +++ b/test/Data/Text/ParagraphLayoutSpec.hs @@ -117,19 +117,19 @@ indentedList :: String -> [String] -> [String] indentedList indent items = prefixTail indent $ suffixInit commaNewline items suffixInit :: String -> [String] -> [String] -suffixInit suffix = mapInit (++suffix) +suffixInit suffix = mapInit (++ suffix) mapInit :: (a -> a) -> [a] -> [a] mapInit _ [] = [] mapInit _ [x] = [x] -mapInit f (x:y:ys) = f x : mapInit f (y:ys) +mapInit f (x : y : ys) = f x : mapInit f (y : ys) prefixTail :: String -> [String] -> [String] -prefixTail prefix = mapTail (prefix++) +prefixTail prefix = mapTail (prefix ++) mapTail :: (a -> a) -> [a] -> [a] mapTail _ [] = [] -mapTail f (x:xs) = x:(map f xs) +mapTail f (x : xs) = x : (map f xs) indent0 :: String indent0 = "" -- 2.30.2