File tree 4 files changed +16
-6
lines changed
lib/Language/Haskell/Stylish
tests/Language/Haskell/Stylish/Step/Data 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ steps:
90
90
# # Default: false
91
91
# break_enums: false
92
92
#
93
+ # # Whether or not to break newtype types before `=` sign
94
+ # #
95
+ # # Default: true
96
+ # break_newtypes: true
97
+ #
93
98
# # Whether or not to break single constructor data types before `=` sign
94
99
# #
95
100
# # Default: true
Original file line number Diff line number Diff line change @@ -251,6 +251,7 @@ parseRecords c o = Data.step
251
251
<*> (o A. .: " field_comment" )
252
252
<*> (o A. .: " deriving" )
253
253
<*> (o A. .:? " break_enums" A. .!= False )
254
+ <*> (o A. .:? " break_newtypes" A. .!= True )
254
255
<*> (o A. .:? " break_single_constructors" A. .!= True )
255
256
<*> (o A. .: " via" >>= parseIndent)
256
257
<*> (o A. .:? " curried_context" A. .!= False )
Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ data Config = Config
60
60
-- ^ Indent before @deriving@ lines (measured from column 0)
61
61
, cBreakEnums :: ! Bool
62
62
-- ^ Break enums by newlines and follow the above rules
63
+ , cBreakNewtypes :: ! Bool
64
+ -- ^ Break newtypes by newlines and follow the above rules
63
65
, cBreakSingleConstructors :: ! Bool
64
66
-- ^ Break single constructors when enabled, e.g. @Indent 2@ will not cause newline after @=@
65
67
, cVia :: ! Indent
@@ -79,6 +81,7 @@ defaultConfig = Config
79
81
, cFieldComment = 2
80
82
, cDeriving = 4
81
83
, cBreakEnums = True
84
+ , cBreakNewtypes = True
82
85
, cBreakSingleConstructors = False
83
86
, cVia = Indent 4
84
87
, cSortDeriving = True
@@ -155,6 +158,7 @@ putDataDecl cfg@Config {..} decl = do
155
158
when (hasConstructors decl) do
156
159
case (cEquals, cFirstField) of
157
160
(_, Indent x) | isEnum decl && cBreakEnums -> newline >> spaces x
161
+ (_, _) | if isNewtype decl then not cBreakNewtypes else singleConstructor decl && not cBreakSingleConstructors -> space
158
162
(_, _)
159
163
| not (isNewtype decl)
160
164
, singleConstructor decl && not cBreakSingleConstructors ->
Original file line number Diff line number Diff line change @@ -1382,19 +1382,19 @@ case66 = assertSnippet (step indentIndentStyle) input input
1382
1382
]
1383
1383
1384
1384
sameSameStyle :: Config
1385
- sameSameStyle = Config SameLine SameLine 2 2 False True SameLine False True NoMaxColumns
1385
+ sameSameStyle = Config SameLine SameLine 2 2 False True True SameLine False True NoMaxColumns
1386
1386
1387
1387
sameIndentStyle :: Config
1388
- sameIndentStyle = Config SameLine (Indent 2 ) 2 2 False True SameLine False True NoMaxColumns
1388
+ sameIndentStyle = Config SameLine (Indent 2 ) 2 2 False True True SameLine False True NoMaxColumns
1389
1389
1390
1390
indentSameStyle :: Config
1391
- indentSameStyle = Config (Indent 2 ) SameLine 2 2 False True SameLine False True NoMaxColumns
1391
+ indentSameStyle = Config (Indent 2 ) SameLine 2 2 False True True SameLine False True NoMaxColumns
1392
1392
1393
1393
indentIndentStyle :: Config
1394
- indentIndentStyle = Config (Indent 2 ) (Indent 2 ) 2 2 False True SameLine False True NoMaxColumns
1394
+ indentIndentStyle = Config (Indent 2 ) (Indent 2 ) 2 2 False True True SameLine False True NoMaxColumns
1395
1395
1396
1396
indentIndentStyle4 :: Config
1397
- indentIndentStyle4 = Config (Indent 4 ) (Indent 4 ) 4 4 False True SameLine False True NoMaxColumns
1397
+ indentIndentStyle4 = Config (Indent 4 ) (Indent 4 ) 4 4 False True True SameLine False True NoMaxColumns
1398
1398
1399
1399
sameSameNoSortStyle :: Config
1400
- sameSameNoSortStyle = Config SameLine SameLine 2 2 False True SameLine False False NoMaxColumns
1400
+ sameSameNoSortStyle = Config SameLine SameLine 2 2 False True True SameLine False False NoMaxColumns
You can’t perform that action at this time.
0 commit comments