Commit dc62c76
authored
Generalise break_only_where to allow single-line module headers (#349)
Previously, the `break_only_where` option of `module_header` allowed choosing
between the following two styles:
1. `break_only_where: false`:
```haskell
module Foo where
module Bar
( main
) where
```
2. `break_only_where: true`:
```haskell
module Foo
where
module Bar
( main
) where
```
In case a module only has a single export (e.g., `main` or `tests`) or no
exports at all (e.g., a module defining orphans), we still "break" the `where`:
```haskell
module Bar
( main
) where
module Orphans
(
) where
```
It should be possible to print these module headers as:
```haskell
module Bar (main) where
module Orphans () where
```
We generalise the `break_only_where` option to `break_where` with the following
three possible values:
- `exports`: only break when there is an explicit export list.
- `single`: only break when the export list counts more than one export.
- `inline`: only break when the export list is too long. This is determined by
the `columns` setting. Not applicable when the export list contains comments
as newlines will be required.
- `always`: always break before the `where`.1 parent 95e2261 commit dc62c76
File tree
5 files changed
+258
-63
lines changed- data
- lib/Language/Haskell/Stylish
- Step
- tests/Language/Haskell/Stylish/Step/ModuleHeader
5 files changed
+258
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
207 | 216 | | |
208 | 217 | | |
209 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
427 | 428 | | |
428 | 429 | | |
429 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
430 | 442 | | |
431 | 443 | | |
432 | 444 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
49 | 56 | | |
50 | 57 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | | - | |
58 | | - | |
| 64 | + | |
| 65 | + | |
59 | 66 | | |
60 | | - | |
61 | | - | |
| 67 | + | |
| 68 | + | |
62 | 69 | | |
63 | 70 | | |
64 | 71 | | |
| |||
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
76 | | - | |
77 | | - | |
| 83 | + | |
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
| |||
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
147 | | - | |
148 | | - | |
| 153 | + | |
| 154 | + | |
149 | 155 | | |
150 | 156 | | |
151 | | - | |
| 157 | + | |
152 | 158 | | |
153 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
154 | 174 | | |
155 | 175 | | |
156 | 176 | | |
| |||
164 | 184 | | |
165 | 185 | | |
166 | 186 | | |
167 | | - | |
168 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
169 | 204 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 205 | + | |
173 | 206 | | |
174 | 207 | | |
175 | 208 | | |
| |||
191 | 224 | | |
192 | 225 | | |
193 | 226 | | |
194 | | - | |
195 | | - | |
196 | 227 | | |
197 | 228 | | |
198 | | - | |
| 229 | + | |
199 | 230 | | |
200 | 231 | | |
201 | 232 | | |
| |||
204 | 235 | | |
205 | 236 | | |
206 | 237 | | |
207 | | - | |
| 238 | + | |
208 | 239 | | |
209 | 240 | | |
210 | 241 | | |
| |||
216 | 247 | | |
217 | 248 | | |
218 | 249 | | |
219 | | - | |
| 250 | + | |
220 | 251 | | |
221 | 252 | | |
222 | 253 | | |
223 | 254 | | |
224 | 255 | | |
225 | 256 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
0 commit comments