on master help sign in
Make the first newline optional on class declarations
af907ecUtku Demir
data/examples/declaration/class/default-implementations-out.hs−2
@@ -1,12 +1,10 @@
1-- | Foo
1-- | Foo
2class Foo a where
2class Foo a where
3−
4 foo :: a -> a
3 foo :: a -> a
5 foo a = a
4 foo a = a
6
5
7-- | Bar
6-- | Bar
8class Bar a where
7class Bar a where
9−
10 bar
8 bar
11 :: a
9 :: a
12 -> Int
10 -> Int
data/examples/declaration/class/functional-dependencies-out.hs−1
@@ -13,5 +13,4 @@ class
13 a c -> b d, -- Baz
13 a c -> b d, -- Baz
14 a c d -> b,
14 a c d -> b,
15 a b d -> a b c d where
15 a b d -> a b c d where
16−
17 baz :: a -> b
16 baz :: a -> b
data/examples/declaration/class/multi-parameters1-out.hs−2
@@ -4,7 +4,6 @@ class Foo a b where foo :: a -> b
4
4
5-- | Something.
5-- | Something.
6class Bar a b c d where
6class Bar a b c d where
7−
8 bar
7 bar
9 :: a
8 :: a
10 -> b
9 -> b
@@ -13,5 +12,4 @@ class Bar a b c d where
13
12
14class -- Before name
13class -- Before name
15 Baz where
14 Baz where
16−
17 baz :: Int
15 baz :: Int
data/examples/declaration/class/single-parameters-out.hs−2
@@ -3,12 +3,10 @@ class Foo a where foo :: a
3
3
4-- | Something more.
4-- | Something more.
5class Bar a where
5class Bar a where
6−
7 -- | Bar
6 -- | Bar
8 bar :: a -> a -> a
7 bar :: a -> a -> a
9
8
10class Baz a where
9class Baz a where
11−
12 -- | Baz
10 -- | Baz
13 baz
11 baz
14 :: ( a,
12 :: ( 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
67 unless (null allDecls) $ do
67 unless (null allDecls) $ do
68 txt " where"
68 txt " where"
69 breakpoint -- Ensure whitespace is added after where clause.
69 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'
71 inci (p_hsDecls Associated allDecls)
73 inci (p_hsDecls Associated allDecls)
72
74
73p_classContext :: LHsContext GhcPs -> R ()
75p_classContext :: LHsContext GhcPs -> R ()