fourmolu 0.10.0.0 → 0.10.1.0
raw patch · 18 files changed
+163/−7 lines, 18 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Ormolu.Utils: splitDocString :: HsDocString -> [Text]
+ Ormolu.Utils: splitDocString :: Bool -> HsDocString -> [Text]
Files
- CHANGELOG.md +5/−0
- data/fourmolu/haddock-style/input.hs +9/−0
- data/fourmolu/haddock-style/output-HaddockMultiLine-module=HaddockMultiLine.hs +11/−0
- data/fourmolu/haddock-style/output-HaddockMultiLine-module=HaddockMultiLineCompact.hs +11/−0
- data/fourmolu/haddock-style/output-HaddockMultiLine-module=HaddockSingleLine.hs +11/−0
- data/fourmolu/haddock-style/output-HaddockMultiLine.hs +11/−0
- data/fourmolu/haddock-style/output-HaddockMultiLineCompact-module=HaddockMultiLine.hs +11/−0
- data/fourmolu/haddock-style/output-HaddockMultiLineCompact-module=HaddockMultiLineCompact.hs +11/−0
- data/fourmolu/haddock-style/output-HaddockMultiLineCompact-module=HaddockSingleLine.hs +11/−0
- data/fourmolu/haddock-style/output-HaddockMultiLineCompact.hs +11/−0
- data/fourmolu/haddock-style/output-HaddockSingleLine-module=HaddockMultiLine.hs +9/−0
- data/fourmolu/haddock-style/output-HaddockSingleLine-module=HaddockMultiLineCompact.hs +9/−0
- data/fourmolu/haddock-style/output-HaddockSingleLine-module=HaddockSingleLine.hs +9/−0
- data/fourmolu/haddock-style/output-HaddockSingleLine.hs +9/−0
- fourmolu.cabal +1/−1
- src/Ormolu/Diff/ParseResult.hs +1/−1
- src/Ormolu/Printer/Meat/Common.hs +6/−1
- src/Ormolu/Utils.hs +17/−4
CHANGELOG.md view
@@ -1,3 +1,8 @@+## Fourmolu 0.10.1.0++* Fix bug where using `{-` in a single-line comment would wrongfully escape it ([#265](https://github.com/fourmolu/fourmolu/issues/265))+* Fix idempotence bug with indented multiline comments ([#273](https://github.com/fourmolu/fourmolu/issues/273))+ ## Fourmolu 0.10.0.0 New options:
data/fourmolu/haddock-style/input.hs view
@@ -18,6 +18,11 @@ -} multi2 :: Int +{- | This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ -- | This is a haddock -- -- with two consecutive newlines@@ -27,3 +32,7 @@ foo :: Int foo = 42 +-- | This is a haddock containing another haddock+--+-- > {-# LANGUAGE ScopedTypeVariables #-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockMultiLine-module=HaddockMultiLine.hs view
@@ -20,6 +20,11 @@ -} multi2 :: Int +{- | This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ {- | This is a haddock with two consecutive newlines@@ -29,3 +34,9 @@ -} foo :: Int foo = 42++{- | This is a haddock containing another haddock++> {\-# LANGUAGE ScopedTypeVariables #-\}+-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockMultiLine-module=HaddockMultiLineCompact.hs view
@@ -20,6 +20,11 @@ -} multi2 :: Int +{- | This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ {- | This is a haddock with two consecutive newlines@@ -29,3 +34,9 @@ -} foo :: Int foo = 42++{- | This is a haddock containing another haddock++> {\-# LANGUAGE ScopedTypeVariables #-\}+-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockMultiLine-module=HaddockSingleLine.hs view
@@ -19,6 +19,11 @@ -} multi2 :: Int +{- | This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ {- | This is a haddock with two consecutive newlines@@ -28,3 +33,9 @@ -} foo :: Int foo = 42++{- | This is a haddock containing another haddock++> {\-# LANGUAGE ScopedTypeVariables #-\}+-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockMultiLine.hs view
@@ -20,6 +20,11 @@ -} multi2 :: Int +{- | This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ {- | This is a haddock with two consecutive newlines@@ -29,3 +34,9 @@ -} foo :: Int foo = 42++{- | This is a haddock containing another haddock++> {\-# LANGUAGE ScopedTypeVariables #-\}+-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockMultiLineCompact-module=HaddockMultiLine.hs view
@@ -20,6 +20,11 @@ -} multi2 :: Int +{-| This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ {-| This is a haddock with two consecutive newlines@@ -29,3 +34,9 @@ -} foo :: Int foo = 42++{-| This is a haddock containing another haddock++> {\-# LANGUAGE ScopedTypeVariables #-\}+-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockMultiLineCompact-module=HaddockMultiLineCompact.hs view
@@ -20,6 +20,11 @@ -} multi2 :: Int +{-| This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ {-| This is a haddock with two consecutive newlines@@ -29,3 +34,9 @@ -} foo :: Int foo = 42++{-| This is a haddock containing another haddock++> {\-# LANGUAGE ScopedTypeVariables #-\}+-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockMultiLineCompact-module=HaddockSingleLine.hs view
@@ -19,6 +19,11 @@ -} multi2 :: Int +{-| This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ {-| This is a haddock with two consecutive newlines@@ -28,3 +33,9 @@ -} foo :: Int foo = 42++{-| This is a haddock containing another haddock++> {\-# LANGUAGE ScopedTypeVariables #-\}+-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockMultiLineCompact.hs view
@@ -20,6 +20,11 @@ -} multi2 :: Int +{-| This is a multiline haddock+ with indentation+-}+multi_indentation :: Int+ {-| This is a haddock with two consecutive newlines@@ -29,3 +34,9 @@ -} foo :: Int foo = 42++{-| This is a haddock containing another haddock++> {\-# LANGUAGE ScopedTypeVariables #-\}+-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockSingleLine-module=HaddockMultiLine.hs view
@@ -18,6 +18,10 @@ -- function haddock multi2 :: Int +-- | This is a multiline haddock+-- with indentation+multi_indentation :: Int+ -- | This is a haddock -- -- with two consecutive newlines@@ -26,3 +30,8 @@ -- https://github.com/fourmolu/fourmolu/issues/172 foo :: Int foo = 42++-- | This is a haddock containing another haddock+--+-- > {-# LANGUAGE ScopedTypeVariables #-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockSingleLine-module=HaddockMultiLineCompact.hs view
@@ -18,6 +18,10 @@ -- function haddock multi2 :: Int +-- | This is a multiline haddock+-- with indentation+multi_indentation :: Int+ -- | This is a haddock -- -- with two consecutive newlines@@ -26,3 +30,8 @@ -- https://github.com/fourmolu/fourmolu/issues/172 foo :: Int foo = 42++-- | This is a haddock containing another haddock+--+-- > {-# LANGUAGE ScopedTypeVariables #-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockSingleLine-module=HaddockSingleLine.hs view
@@ -17,6 +17,10 @@ -- function haddock multi2 :: Int +-- | This is a multiline haddock+-- with indentation+multi_indentation :: Int+ -- | This is a haddock -- -- with two consecutive newlines@@ -25,3 +29,8 @@ -- https://github.com/fourmolu/fourmolu/issues/172 foo :: Int foo = 42++-- | This is a haddock containing another haddock+--+-- > {-# LANGUAGE ScopedTypeVariables #-}+haddock_in_haddock :: Int
data/fourmolu/haddock-style/output-HaddockSingleLine.hs view
@@ -17,6 +17,10 @@ -- function haddock multi2 :: Int +-- | This is a multiline haddock+-- with indentation+multi_indentation :: Int+ -- | This is a haddock -- -- with two consecutive newlines@@ -25,3 +29,8 @@ -- https://github.com/fourmolu/fourmolu/issues/172 foo :: Int foo = 42++-- | This is a haddock containing another haddock+--+-- > {-# LANGUAGE ScopedTypeVariables #-}+haddock_in_haddock :: Int
fourmolu.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: fourmolu-version: 0.10.0.0+version: 0.10.1.0 license: BSD-3-Clause license-file: LICENSE.md maintainer:
src/Ormolu/Diff/ParseResult.hs view
@@ -129,7 +129,7 @@ case cast str1' :: Maybe HsDocString of Nothing -> Different [] Just str1 ->- if splitDocString str0 == splitDocString str1+ if splitDocString True str0 == splitDocString True str1 then Same else Different [] forLocated ::
src/Ormolu/Printer/Meat/Common.hs view
@@ -165,7 +165,12 @@ -- Make sure the Haddock is separated by a newline from other comments. when goesAfterComment newline - let docStringLines = splitDocString $ hsDocString str+ let shouldEscapeCommentBraces =+ case poHStyle of+ HaddockSingleLine -> False+ HaddockMultiLine -> True+ HaddockMultiLineCompact -> True+ let docStringLines = splitDocString shouldEscapeCommentBraces $ hsDocString str mSrcSpan <- getSrcSpan l
src/Ormolu/Utils.hs view
@@ -68,15 +68,15 @@ -- | Split and normalize a doc string. The result is a list of lines that -- make up the comment.-splitDocString :: HsDocString -> [Text]-splitDocString docStr =+splitDocString :: Bool -> HsDocString -> [Text]+splitDocString shouldEscapeCommentBraces docStr = case r of [] -> [""] _ -> r where r = fmap (escapeLeadingDollar . escapeCommentBraces)- . dropPaddingSpace+ . dropPaddingSpace' . dropWhileEnd T.null . fmap (T.stripEnd . T.pack) . lines@@ -88,6 +88,16 @@ case T.uncons txt of Just ('$', _) -> T.cons '\\' txt _ -> txt+ dropPaddingSpace' =+ case docStr of+ -- comments using '--'+ MultiLineDocString {} -> dropPaddingSpace+ -- comments using '{-'+ NestedDocString {} -> \case+ x : xs | Just (' ', x') <- T.uncons x -> x' : xs+ xs -> xs+ -- don't care about generated+ GeneratedDocString {} -> id dropPaddingSpace xs = case dropWhile T.null xs of [] -> []@@ -102,7 +112,10 @@ in if leadingSpace x then dropSpace <$> xs else xs- escapeCommentBraces = T.replace "{-" "{\\-" . T.replace "-}" "-\\}"+ escapeCommentBraces =+ if shouldEscapeCommentBraces+ then T.replace "{-" "{\\-" . T.replace "-}" "-\\}"+ else id -- | Increment line number in a 'SrcSpan'. incSpanLine :: Int -> SrcSpan -> SrcSpan