Make the first newline optional on class declarations
commitaf907ecb9ee675154fdf6b352506fd05b7081b71
authorUtku Demir <me@utdemir.com>
dateMon 26 Aug 2019, 13:17 (7 years ago)
parent25c609c
data/examples/declaration/class/default-implementations-out.hs−2
@@ -1,12 +1,10 @@
11-- | Foo
22class Foo a where
3−
43 foo :: a -> a
54 foo a = a
65
76-- | Bar
87class Bar a where
9−
108 bar
119 :: a
1210 -> Int
data/examples/declaration/class/functional-dependencies-out.hs−1
@@ -13,5 +13,4 @@ class
1313 a c -> b d, -- Baz
1414 a c d -> b,
1515 a b d -> a b c d where
16−
1716 baz :: a -> b
data/examples/declaration/class/multi-parameters1-out.hs−2
@@ -4,7 +4,6 @@ class Foo a b where foo :: a -> b
44
55-- | Something.
66class Bar a b c d where
7−
87 bar
98 :: a
109 -> b
@@ -13,5 +12,4 @@ class Bar a b c d where
1312
1413class -- Before name
1514 Baz where
16−
1715 baz :: Int
data/examples/declaration/class/single-parameters-out.hs−2
@@ -3,12 +3,10 @@ class Foo a where foo :: a
33
44-- | Something more.
55class Bar a where
6−
76 -- | Bar
87 bar :: a -> a -> a
98
109class Baz a where
11−
1210 -- | Baz
1311 baz
1412 :: ( a,
src/Ormolu/Printer/Meat/Declaration/Class.hs+3−1
@@ -67,7 +67,9 @@ p_classDecl ctx name tvars fixity fdeps csigs cdefs cats catdefs = do
6767 unless (null allDecls) $ do
6868 txt " where"
6969 breakpoint -- Ensure whitespace is added after where clause.
70− breakpoint' -- Add newline before first declaration.
70+ -- Add newline before first declaration if the body contains separate
71+ -- declarations
72+ when (hasSeparatedDecls $ map unLoc allDecls) breakpoint'
7173 inci (p_hsDecls Associated allDecls)
7274
7375p_classContext :: LHsContext GhcPs -> R ()