packages feed

fourmolu 0.16.1.0 → 0.16.2.0

raw patch · 37 files changed

+127/−71 lines, 37 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,16 @@+## Fourmolu 0.16.2.0++### Upstream changes:++#### Ormolu 0.7.7.0++* Use single-line layout for parens around single-line content. [Issue+  1120](https://github.com/tweag/ormolu/issues/1120).++* Allow function arguments to be on the same line even if the full type+  (with constraints and foralls) are on multiple lines. [PR+  1125](https://github.com/tweag/ormolu/pull/1125).+ ## Fourmolu 0.16.1.0  ### Upstream changes:
data/examples/declaration/class/default-signatures-four-out.hs view
@@ -14,9 +14,7 @@         ( Read a         , Semigroup a         ) =>-        a ->-        a ->-        a+        a -> a -> a     -- Even more pointless comment     bar         a
data/examples/declaration/class/default-signatures-out.hs view
@@ -14,9 +14,7 @@     ( Read a,       Semigroup a     ) =>-    a ->-    a ->-    a+    a -> a -> a   -- Even more pointless comment   bar     a
data/examples/declaration/data/gadt/multiline-four-out.hs view
@@ -9,9 +9,7 @@         forall a b.         (Show a, Eq b) => -- foo         -- bar-        a ->-        b ->-        Foo 'Int+        a -> b -> Foo 'Int     -- | But 'Bar' is also not too bad.     Bar ::         Int -> Maybe Text -> Foo 'Bool
data/examples/declaration/data/gadt/multiline-out.hs view
@@ -9,9 +9,7 @@     forall a b.     (Show a, Eq b) => -- foo     -- bar-    a ->-    b ->-    Foo 'Int+    a -> b -> Foo 'Int   -- | But 'Bar' is also not too bad.   Bar ::     Int -> Maybe Text -> Foo 'Bool
data/examples/declaration/rewrite-rule/type-signature-four-out.hs view
@@ -8,9 +8,7 @@     z     ( g ::         forall b.-        (a -> b -> b) ->-        b ->-        b+        (a -> b -> b) -> b -> b     ).     foldr k z (build g) =         g k z
data/examples/declaration/rewrite-rule/type-signature-out.hs view
@@ -8,9 +8,7 @@   z   ( g ::       forall b.-      (a -> b -> b) ->-      b ->-      b+      (a -> b -> b) -> b -> b   ).   foldr k z (build g) =     g k z
data/examples/declaration/signature/specialize/specialize-instance-four-out.hs view
@@ -7,7 +7,6 @@  instance (Num r, V.Vector v r, Factored m r) => Num (VT v m r) where     {-# SPECIALIZE instance-        ( (Factored m Int) => Num (VT U.Vector m Int)-        )+        ((Factored m Int) => Num (VT U.Vector m Int))         #-}     VT x + VT y = VT $ V.zipWith (+) x y
data/examples/declaration/signature/specialize/specialize-instance-out.hs view
@@ -8,7 +8,6 @@  instance (Num r, V.Vector v r, Factored m r) => Num (VT v m r) where   {-# SPECIALIZE instance-    ( (Factored m Int) => Num (VT U.Vector m Int)-    )+    ((Factored m Int) => Num (VT U.Vector m Int))     #-}   VT x + VT y = VT $ V.zipWith (+) x y
data/examples/declaration/splice/typed-splice-four-out.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE TemplateHaskell #-}  x =-    $$( foo bar-      )+    $$(foo bar)  x = $$foo
data/examples/declaration/splice/typed-splice-out.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE TemplateHaskell #-}  x =-  $$( foo bar-    )+  $$(foo bar)  x = $$foo
+ data/examples/declaration/type/parens-comments-four-out.hs view
@@ -0,0 +1,4 @@+type Test =+    ( -- a+      x+    )
+ data/examples/declaration/type/parens-comments-out.hs view
@@ -0,0 +1,4 @@+type Test =+  ( -- a+    x+  )
+ data/examples/declaration/type/parens-comments.hs view
@@ -0,0 +1,3 @@+type Test = (+  -- a+  x)
data/examples/declaration/value/function/application-2-four-out.hs view
@@ -1,13 +1,11 @@ {-# LANGUAGE TemplateHaskell #-}  foo = do-    $( bar-     )+    $(bar)         baz  foo = do-    $$( bar-      )+    $$(bar)         baz  foo = do
data/examples/declaration/value/function/application-2-out.hs view
@@ -1,13 +1,11 @@ {-# LANGUAGE TemplateHaskell #-}  foo = do-  $( bar-   )+  $(bar)     baz  foo = do-  $$( bar-    )+  $$(bar)     baz  foo = do
data/examples/declaration/value/function/arrow/proc-parentheses-four-out.hs view
@@ -4,8 +4,7 @@  bar f g = proc a ->     ( ( (f)-            ( g-            )+            (g)       )         -<             ( ( ( ( ( ( g
data/examples/declaration/value/function/arrow/proc-parentheses-out.hs view
@@ -4,8 +4,7 @@  bar f g = proc a ->   ( ( (f)-        ( g-        )+        (g)     )       -<         ( ( ( ( ( ( g
data/examples/declaration/value/function/fancy-forall-0-four-out.hs view
@@ -6,5 +6,4 @@       HasCatch innertag inner (t m')     , HasCatch outertag outer m     ) =>-    (forall m'. (HasCatch innertag inner m') => m' a) ->-    m a+    (forall m'. (HasCatch innertag inner m') => m' a) -> m a
data/examples/declaration/value/function/fancy-forall-0-out.hs view
@@ -6,5 +6,4 @@     HasCatch innertag inner (t m'),     HasCatch outertag outer m   ) =>-  (forall m'. (HasCatch innertag inner m') => m' a) ->-  m a+  (forall m'. (HasCatch innertag inner m') => m' a) -> m a
data/examples/declaration/value/function/fancy-forall-1-four-out.hs view
@@ -6,5 +6,4 @@       HasReader innertag inner (t m')     , HasReader outertag outer m     ) =>-    (forall m'. (HasReader innertag inner m') => m' a) ->-    m a+    (forall m'. (HasReader innertag inner m') => m' a) -> m a
data/examples/declaration/value/function/fancy-forall-1-out.hs view
@@ -6,5 +6,4 @@     HasReader innertag inner (t m'),     HasReader outertag outer m   ) =>-  (forall m'. (HasReader innertag inner m') => m' a) ->-  m a+  (forall m'. (HasReader innertag inner m') => m' a) -> m a
data/examples/declaration/value/function/implicit-params-four-out.hs view
@@ -11,6 +11,5 @@         a -> a -> Bool     , ?foo :: Int     ) =>-    [a] ->-    [a]+    [a] -> [a] sort' = sort
data/examples/declaration/value/function/implicit-params-out.hs view
@@ -11,6 +11,5 @@       a -> a -> Bool,     ?foo :: Int   ) =>-  [a] ->-  [a]+  [a] -> [a] sort' = sort
+ data/examples/declaration/value/function/multiline-types-four-out.hs view
@@ -0,0 +1,17 @@+foo ::+    (Monad m, Show a) =>+    a ->+    m String+bar ::+    ( Monad m+    , Show a+    ) =>+    a -> m String+multiConstraints ::+    (Show a) =>+    a ->+    a ->+    a ->+    (Eq a) =>+    (Num a) =>+    a -> a -> ()
+ data/examples/declaration/value/function/multiline-types-out.hs view
@@ -0,0 +1,17 @@+foo ::+  (Monad m, Show a) =>+  a ->+  m String+bar ::+  ( Monad m,+    Show a+  ) =>+  a -> m String+multiConstraints ::+  (Show a) =>+  a ->+  a ->+  a ->+  (Eq a) =>+  (Num a) =>+  a -> a -> ()
+ data/examples/declaration/value/function/multiline-types.hs view
@@ -0,0 +1,15 @@+foo ::+   (Monad m, Show a) =>+   a ->+   m String++bar ::+   (Monad m,+      Show a) =>+   a -> m String++multiConstraints ::+  Show a =>+  a -> a -> a ->+  Eq a => Num a =>+  a -> a -> ()
+ data/examples/declaration/value/function/parens-comments-four-out.hs view
@@ -0,0 +1,4 @@+test =+    ( -- a+      x+    )
+ data/examples/declaration/value/function/parens-comments-out.hs view
@@ -0,0 +1,4 @@+test =+  ( -- a+    x+  )
+ data/examples/declaration/value/function/parens-comments.hs view
@@ -0,0 +1,3 @@+test = (+  -- a+  x)
data/examples/other/multiline-forall-four-out.hs view
@@ -22,8 +22,7 @@             )             (x :: *)             (y :: *).-        f x y ->-        G+        f x y -> G  f ::     forall@@ -32,8 +31,7 @@         )         (x :: *)         (y :: *).-    f x y ->-    ()+    f x y -> () f = const ()  type family T f x y where
data/examples/other/multiline-forall-out.hs view
@@ -22,8 +22,7 @@       )       (x :: *)       (y :: *).-    f x y ->-    G+    f x y -> G  f ::   forall@@ -32,8 +31,7 @@     )     (x :: *)     (y :: *).-  f x y ->-  ()+  f x y -> () f = const ()  type family T f x y where
fourmolu.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               fourmolu-version:            0.16.1.0+version:            0.16.2.0 license:            BSD-3-Clause license-file:       LICENSE.md maintainer:
src/Ormolu/Printer/Meat/Declaration/Class.hs view
@@ -50,8 +50,7 @@       tyFams = (getLocA &&& fmap (TyClD NoExtField . FamDecl NoExtField)) <$> cats       docs = (getLocA &&& fmap (DocD NoExtField)) <$> cdocs       tyFamDefs =-        ( getLocA &&& fmap (InstD NoExtField . TyFamInstD NoExtField)-        )+        (getLocA &&& fmap (InstD NoExtField . TyFamInstD NoExtField))           <$> catdefs       allDecls =         snd <$> sortBy (leftmost_smallest `on` fst) (sigs <> vals <> tyFams <> tyFamDefs <> docs)
src/Ormolu/Printer/Meat/Declaration/Instance.hs view
@@ -70,12 +70,10 @@   let sigs = (getLocA &&& fmap (SigD NoExtField)) <$> cid_sigs       vals = (getLocA &&& fmap (ValD NoExtField)) <$> toList cid_binds       tyFamInsts =-        ( getLocA &&& fmap (InstD NoExtField . TyFamInstD NoExtField)-        )+        (getLocA &&& fmap (InstD NoExtField . TyFamInstD NoExtField))           <$> cid_tyfam_insts       dataFamInsts =-        ( getLocA &&& fmap (InstD NoExtField . DataFamInstD NoExtField)-        )+        (getLocA &&& fmap (InstD NoExtField . DataFamInstD NoExtField))           <$> cid_datafam_insts       allDecls =         snd <$> sortBy (leftmost_smallest `on` fst) (sigs <> vals <> tyFamInsts <> dataFamInsts)
src/Ormolu/Printer/Meat/Declaration/Value.hs view
@@ -715,8 +715,11 @@     -- negated literals, as `- 1` and `-1` have differing AST.     when (negativeLiterals && isLiteral) space     located e p_hsExpr-  HsPar _ e ->-    parens s $ sitcc (located e (dontUseBraces . p_hsExpr))+  HsPar _ e -> do+    csSpans <-+      fmap (flip RealSrcSpan Strict.Nothing . getLoc) <$> getEnclosingComments+    switchLayout (locA e : csSpans) $+      parens s (sitcc $ located e (dontUseBraces . p_hsExpr))   SectionL _ x op -> do     located x p_hsExpr     breakpoint
src/Ormolu/Printer/Meat/Type.hs view
@@ -26,6 +26,7 @@ import Control.Monad import Data.Choice (pattern With, pattern Without) import Data.Functor ((<&>))+import GHC.Data.Strict qualified as Strict import GHC.Hs hiding (isPromoted) import GHC.Types.SourceText import GHC.Types.SrcLoc@@ -53,7 +54,7 @@     getPrinterOpt poFunctionArrows >>= \case       LeadingArrows | multilineArgs -> interArgBreak >> txt " " >> p_forallBndrsEnd vis       _ -> p_forallBndrsEnd vis >> interArgBreak-    p_hsTypeR (unLoc t)+    located t p_hsType   HsQualTy _ qs t -> do     located qs p_hsContext     getPrinterOpt poFunctionArrows >>= \case@@ -62,7 +63,7 @@       LeadingArgsArrows -> space >> token'darrow >> interArgBreak     case unLoc t of       HsQualTy {} -> p_hsTypeR (unLoc t)-      HsFunTy {} -> p_hsTypeR (unLoc t)+      HsFunTy {} -> located t p_hsType       _ -> located t p_hsTypeR   HsTyVar _ p n -> do     case p of@@ -128,8 +129,11 @@     let opTree = BinaryOpBranches (tyOpTree x) op (tyOpTree y)     p_tyOpTree       (reassociateOpTree debug (Just . unLoc) modFixityMap opTree)-  HsParTy _ t ->-    parens N $ sitcc $ located t p_hsType+  HsParTy _ t -> do+    csSpans <-+      fmap (flip RealSrcSpan Strict.Nothing . getLoc) <$> getEnclosingComments+    switchLayout (locA t : csSpans) $+      parens N (sitcc $ located t p_hsType)   HsIParamTy _ n t -> sitcc $ do     located n atom     inci $ startTypeAnnotation t p_hsType