on master help sign in
Always surround the class to derive with parentheses
68bbc64waddlaw
data/examples/declaration/data/deriving-out.hsnew file+2
@@ -0,0 +1,2 @@
1+newtype R r a = R (ReaderT r IO a)
2+ deriving (MonadReader r)
data/examples/declaration/data/deriving-strategies-out.hs+3−3
@@ -5,8 +5,8 @@ newtype Foo = Foo Int
5 ( ToJSON
5 ( ToJSON
6 , FromJSON
6 , FromJSON
7 )
7 )
8− deriving newtype Num
8+ deriving newtype (Num)
9− deriving Monoid via (Sum Int)
9+ deriving (Monoid) via (Sum Int)
10 deriving
10 deriving
11− Semigroup
11+ (Semigroup)
12 via (Sum Int)
12 via (Sum Int)
data/examples/declaration/data/deriving.hsnew file+2
@@ -0,0 +1,2 @@
1+newtype R r a = R (ReaderT r IO a)
2+ deriving (MonadReader r)
data/examples/declaration/data/multiline-arg-parens-out.hs+1−1
@@ -5,4 +5,4 @@ data Foo
5 (Set Baz) -- and here we go
5 (Set Baz) -- and here we go
6 -- and that's it
6 -- and that's it
7 Text
7 Text
8− deriving Eq
8+ deriving (Eq)
data/examples/declaration/data/simple-broken-out.hs+2−2
@@ -1,8 +1,8 @@
1-- | Here we go.
1-- | Here we go.
2data Foo
2data Foo
3 = Foo {unFoo :: Int}
3 = Foo {unFoo :: Int}
4− deriving Eq
4+ deriving (Eq)
5
5
6-- | And once again.
6-- | And once again.
7data Bar = Bar {unBar :: Int}
7data Bar = Bar {unBar :: Int}
8− deriving Eq
8+ deriving (Eq)
src/Ormolu/Printer/Meat/Declaration/Data.hs−1
@@ -142,7 +142,6 @@ p_hsDerivingClause HsDerivingClause {..} = do
142 txt "deriving"
142 txt "deriving"
143 let derivingWhat = located deriv_clause_tys $ \case
143 let derivingWhat = located deriv_clause_tys $ \case
144 [] -> txt "()"
144 [] -> txt "()"
145− [x] -> located (hsib_body x) p_hsType
146 xs -> parens . velt $ withSep comma (located' p_hsType . hsib_body) xs
145 xs -> parens . velt $ withSep comma (located' p_hsType . hsib_body) xs
147 case deriv_clause_strategy of
146 case deriv_clause_strategy of
148 Nothing -> do
147 Nothing -> do