Always surround the class to derive with parentheses
commit68bbc647f783ae2f90e5a455d65a3d095958f91e
authorwaddlaw <ingronze@gmail.com>
dateMon 15 Jul 2019, 11:00 (7 years ago)
parent2cae331
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
55 ( ToJSON
66 , FromJSON
77 )
8− deriving newtype Num
9− deriving Monoid via (Sum Int)
8+ deriving newtype (Num)
9+ deriving (Monoid) via (Sum Int)
1010 deriving
11− Semigroup
11+ (Semigroup)
1212 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
55 (Set Baz) -- and here we go
66 -- and that's it
77 Text
8− deriving Eq
8+ deriving (Eq)
data/examples/declaration/data/simple-broken-out.hs+2−2
@@ -1,8 +1,8 @@
11-- | Here we go.
22data Foo
33 = Foo {unFoo :: Int}
4− deriving Eq
4+ deriving (Eq)
55
66-- | And once again.
77data 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
142142 txt "deriving"
143143 let derivingWhat = located deriv_clause_tys $ \case
144144 [] -> txt "()"
145− [x] -> located (hsib_body x) p_hsType
146145 xs -> parens . velt $ withSep comma (located' p_hsType . hsib_body) xs
147146 case deriv_clause_strategy of
148147 Nothing -> do