packages feed

ormolu 0.7.6.0 → 0.7.7.0

raw patch · 23 files changed

+87/−44 lines, 23 files

Files

CHANGELOG.md view
@@ -1,7 +1,16 @@+## 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).+ ## Ormolu 0.7.6.0 -* Fix Haddock comments on infix constructors-  [Issue 758](https://github.com/tweag/ormolu/issues/758).+* Fix Haddock comments on infix constructors. [Issue+  758](https://github.com/tweag/ormolu/issues/758).  * Don't require a trailing newline in `.ormolu` files. [Issue   1122](https://github.com/tweag/ormolu/issues/1122).
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-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-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-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-out.hs view
@@ -1,7 +1,6 @@ {-# LANGUAGE TemplateHaskell #-}  x =-  $$( foo bar-    )+  $$(foo bar)  x = $$foo
+ 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-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-out.hs view
@@ -4,8 +4,7 @@  bar f g = proc a ->   ( ( (f)-        ( g-        )+        (g)     )       -<         ( ( ( ( ( ( g
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-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-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-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-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-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
ormolu.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               ormolu-version:            0.7.6.0+version:            0.7.7.0 license:            BSD-3-Clause license-file:       LICENSE.md maintainer:         Mark Karpov <mark.karpov@tweag.io>
src/Ormolu/Printer/Meat/Declaration/Class.hs view
@@ -49,8 +49,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
@@ -696,8 +696,11 @@     -- negated literals, as `- 1` and `-1` have differing AST.     when (negativeLiterals && isLiteral) space     located e p_hsExpr-  HsPar _ e ->-    parens s (located e (dontUseBraces . p_hsExpr))+  HsPar _ e -> do+    csSpans <-+      fmap (flip RealSrcSpan Strict.Nothing . getLoc) <$> getEnclosingComments+    switchLayout (locA e : csSpans) $+      parens s (located e (dontUseBraces . p_hsExpr))   SectionL _ x op -> do     located x p_hsExpr     breakpoint
src/Ormolu/Printer/Meat/Type.hs view
@@ -22,6 +22,7 @@ where  import Data.Choice (pattern With)+import GHC.Data.Strict qualified as Strict import GHC.Hs hiding (isPromoted) import GHC.Types.SourceText import GHC.Types.SrcLoc@@ -43,7 +44,7 @@       HsForAllInvis _ bndrs -> p_forallBndrs ForAllInvis p_hsTyVarBndr bndrs       HsForAllVis _ bndrs -> p_forallBndrs ForAllVis p_hsTyVarBndr bndrs     interArgBreak-    p_hsTypeR (unLoc t)+    located t p_hsType   HsQualTy _ qs t -> do     located qs p_hsContext     space@@ -51,7 +52,7 @@     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@@ -117,8 +118,11 @@     let opTree = BinaryOpBranches (tyOpTree x) op (tyOpTree y)     p_tyOpTree       (reassociateOpTree debug (Just . unLoc) modFixityMap opTree)-  HsParTy _ t ->-    parens N (located t p_hsType)+  HsParTy _ t -> do+    csSpans <-+      fmap (flip RealSrcSpan Strict.Nothing . getLoc) <$> getEnclosingComments+    switchLayout (locA t : csSpans) $+      parens N (located t p_hsType)   HsIParamTy _ n t -> sitcc $ do     located n atom     space