Skip to content

Commit c667f04

Browse files
committed
Format with stylish-haskell
Closes #3.
1 parent b5d3beb commit c667f04

File tree

8 files changed

+386
-29
lines changed

8 files changed

+386
-29
lines changed

.stylish-haskell.yaml

+357
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
# stylish-haskell configuration file
2+
# ==================================
3+
4+
# The stylish-haskell tool is mainly configured by specifying steps. These steps
5+
# are a list, so they have an order, and one specific step may appear more than
6+
# once (if needed). Each file is processed by these steps in the given order.
7+
steps:
8+
# Convert some ASCII sequences to their Unicode equivalents. This is disabled
9+
# by default.
10+
# - unicode_syntax:
11+
# # In order to make this work, we also need to insert the UnicodeSyntax
12+
# # language pragma. If this flag is set to true, we insert it when it's
13+
# # not already present. You may want to disable it if you configure
14+
# # language extensions using some other method than pragmas. Default:
15+
# # true.
16+
# add_language_pragma: true
17+
18+
# Format module header
19+
#
20+
# Currently, this option is not configurable and will format all exports and
21+
# module declarations to minimize diffs
22+
#
23+
# - module_header:
24+
# # How many spaces use for indentation in the module header.
25+
# indent: 4
26+
#
27+
# # Should export lists be sorted? Sorting is only performed within the
28+
# # export section, as delineated by Haddock comments.
29+
# sort: true
30+
#
31+
# # See `separate_lists` for the `imports` step.
32+
# separate_lists: true
33+
34+
# Format record definitions. This is disabled by default.
35+
#
36+
# You can control the layout of record fields. The only rules that can't be configured
37+
# are these:
38+
#
39+
# - "|" is always aligned with "="
40+
# - "," in fields is always aligned with "{"
41+
# - "}" is likewise always aligned with "{"
42+
#
43+
# - records:
44+
# # How to format equals sign between type constructor and data constructor.
45+
# # Possible values:
46+
# # - "same_line" -- leave "=" AND data constructor on the same line as the type constructor.
47+
# # - "indent N" -- insert a new line and N spaces from the beginning of the next line.
48+
# equals: "indent 2"
49+
#
50+
# # How to format first field of each record constructor.
51+
# # Possible values:
52+
# # - "same_line" -- "{" and first field goes on the same line as the data constructor.
53+
# # - "indent N" -- insert a new line and N spaces from the beginning of the data constructor
54+
# first_field: "indent 2"
55+
#
56+
# # How many spaces to insert between the column with "," and the beginning of the comment in the next line.
57+
# field_comment: 2
58+
#
59+
# # How many spaces to insert before "deriving" clause. Deriving clauses are always on separate lines.
60+
# deriving: 2
61+
#
62+
# # How many spaces to insert before "via" clause counted from indentation of deriving clause
63+
# # Possible values:
64+
# # - "same_line" -- "via" part goes on the same line as "deriving" keyword.
65+
# # - "indent N" -- insert a new line and N spaces from the beginning of "deriving" keyword.
66+
# via: "indent 2"
67+
#
68+
# # Sort typeclass names in the "deriving" list alphabetically.
69+
# sort_deriving: true
70+
#
71+
# # Wheter or not to break enums onto several lines
72+
# #
73+
# # Default: false
74+
# break_enums: false
75+
#
76+
# # Whether or not to break single constructor data types before `=` sign
77+
# #
78+
# # Default: true
79+
# break_single_constructors: true
80+
#
81+
# # Whether or not to curry constraints on function.
82+
# #
83+
# # E.g: @allValues :: Enum a => Bounded a => Proxy a -> [a]@
84+
# #
85+
# # Instead of @allValues :: (Enum a, Bounded a) => Proxy a -> [a]@
86+
# #
87+
# # Default: false
88+
# curried_context: false
89+
90+
# Align the right hand side of some elements. This is quite conservative
91+
# and only applies to statements where each element occupies a single
92+
# line.
93+
# Possible values:
94+
# - always - Always align statements.
95+
# - adjacent - Align statements that are on adjacent lines in groups.
96+
# - never - Never align statements.
97+
# All default to always.
98+
- simple_align:
99+
cases: always
100+
top_level_patterns: always
101+
records: always
102+
multi_way_if: always
103+
104+
# Import cleanup
105+
- imports:
106+
# There are different ways we can align names and lists.
107+
#
108+
# - global: Align the import names and import list throughout the entire
109+
# file.
110+
#
111+
# - file: Like global, but don't add padding when there are no qualified
112+
# imports in the file.
113+
#
114+
# - group: Only align the imports per group (a group is formed by adjacent
115+
# import lines).
116+
#
117+
# - none: Do not perform any alignment.
118+
#
119+
# Default: global.
120+
align: none
121+
122+
# The following options affect only import list alignment.
123+
#
124+
# List align has following options:
125+
#
126+
# - after_alias: Import list is aligned with end of import including
127+
# 'as' and 'hiding' keywords.
128+
#
129+
# > import qualified Data.List as List (concat, foldl, foldr, head,
130+
# > init, last, length)
131+
#
132+
# - with_alias: Import list is aligned with start of alias or hiding.
133+
#
134+
# > import qualified Data.List as List (concat, foldl, foldr, head,
135+
# > init, last, length)
136+
#
137+
# - with_module_name: Import list is aligned `list_padding` spaces after
138+
# the module name.
139+
#
140+
# > import qualified Data.List as List (concat, foldl, foldr, head,
141+
# init, last, length)
142+
#
143+
# This is mainly intended for use with `pad_module_names: false`.
144+
#
145+
# > import qualified Data.List as List (concat, foldl, foldr, head,
146+
# init, last, length, scanl, scanr, take, drop,
147+
# sort, nub)
148+
#
149+
# - new_line: Import list starts always on new line.
150+
#
151+
# > import qualified Data.List as List
152+
# > (concat, foldl, foldr, head, init, last, length)
153+
#
154+
# - repeat: Repeat the module name to align the import list.
155+
#
156+
# > import qualified Data.List as List (concat, foldl, foldr, head)
157+
# > import qualified Data.List as List (init, last, length)
158+
#
159+
# Default: after_alias
160+
list_align: after_alias
161+
162+
# Right-pad the module names to align imports in a group:
163+
#
164+
# - true: a little more readable
165+
#
166+
# > import qualified Data.List as List (concat, foldl, foldr,
167+
# > init, last, length)
168+
# > import qualified Data.List.Extra as List (concat, foldl, foldr,
169+
# > init, last, length)
170+
#
171+
# - false: diff-safe
172+
#
173+
# > import qualified Data.List as List (concat, foldl, foldr, init,
174+
# > last, length)
175+
# > import qualified Data.List.Extra as List (concat, foldl, foldr,
176+
# > init, last, length)
177+
#
178+
# Default: true
179+
pad_module_names: true
180+
181+
# Long list align style takes effect when import is too long. This is
182+
# determined by 'columns' setting.
183+
#
184+
# - inline: This option will put as much specs on same line as possible.
185+
#
186+
# - new_line: Import list will start on new line.
187+
#
188+
# - new_line_multiline: Import list will start on new line when it's
189+
# short enough to fit to single line. Otherwise it'll be multiline.
190+
#
191+
# - multiline: One line per import list entry.
192+
# Type with constructor list acts like single import.
193+
#
194+
# > import qualified Data.Map as M
195+
# > ( empty
196+
# > , singleton
197+
# > , ...
198+
# > , delete
199+
# > )
200+
#
201+
# Default: inline
202+
long_list_align: inline
203+
204+
# Align empty list (importing instances)
205+
#
206+
# Empty list align has following options
207+
#
208+
# - inherit: inherit list_align setting
209+
#
210+
# - right_after: () is right after the module name:
211+
#
212+
# > import Vector.Instances ()
213+
#
214+
# Default: inherit
215+
empty_list_align: inherit
216+
217+
# List padding determines indentation of import list on lines after import.
218+
# This option affects 'long_list_align'.
219+
#
220+
# - <integer>: constant value
221+
#
222+
# - module_name: align under start of module name.
223+
# Useful for 'file' and 'group' align settings.
224+
#
225+
# Default: 4
226+
list_padding: 4
227+
228+
# Separate lists option affects formatting of import list for type
229+
# or class. The only difference is single space between type and list
230+
# of constructors, selectors and class functions.
231+
#
232+
# - true: There is single space between Foldable type and list of it's
233+
# functions.
234+
#
235+
# > import Data.Foldable (Foldable (fold, foldl, foldMap))
236+
#
237+
# - false: There is no space between Foldable type and list of it's
238+
# functions.
239+
#
240+
# > import Data.Foldable (Foldable(fold, foldl, foldMap))
241+
#
242+
# Default: true
243+
separate_lists: true
244+
245+
# Space surround option affects formatting of import lists on a single
246+
# line. The only difference is single space after the initial
247+
# parenthesis and a single space before the terminal parenthesis.
248+
#
249+
# - true: There is single space associated with the enclosing
250+
# parenthesis.
251+
#
252+
# > import Data.Foo ( foo )
253+
#
254+
# - false: There is no space associated with the enclosing parenthesis
255+
#
256+
# > import Data.Foo (foo)
257+
#
258+
# Default: false
259+
space_surround: false
260+
261+
# Enabling this argument will use the new GHC lib parse to format imports.
262+
#
263+
# This currently assumes a few things, it will assume that you want post
264+
# qualified imports. It is also not as feature complete as the old
265+
# imports formatting.
266+
#
267+
# It does not remove redundant lines or merge lines. As such, the full
268+
# feature scope is still pending.
269+
#
270+
# It _is_ however, a fine alternative if you are using features that are
271+
# not parseable by haskell src extensions and you're comfortable with the
272+
# presets.
273+
#
274+
# Default: false
275+
ghc_lib_parser: false
276+
277+
# Language pragmas
278+
- language_pragmas:
279+
# We can generate different styles of language pragma lists.
280+
#
281+
# - vertical: Vertical-spaced language pragmas, one per line.
282+
#
283+
# - compact: A more compact style.
284+
#
285+
# - compact_line: Similar to compact, but wrap each line with
286+
# `{-#LANGUAGE #-}'.
287+
#
288+
# Default: vertical.
289+
style: vertical
290+
291+
# Align affects alignment of closing pragma brackets.
292+
#
293+
# - true: Brackets are aligned in same column.
294+
#
295+
# - false: Brackets are not aligned together. There is only one space
296+
# between actual import and closing bracket.
297+
#
298+
# Default: true
299+
align: false
300+
301+
# stylish-haskell can detect redundancy of some language pragmas. If this
302+
# is set to true, it will remove those redundant pragmas. Default: true.
303+
remove_redundant: true
304+
305+
# Language prefix to be used for pragma declaration, this allows you to
306+
# use other options non case-sensitive like "language" or "Language".
307+
# If a non correct String is provided, it will default to: LANGUAGE.
308+
language_prefix: LANGUAGE
309+
310+
# Replace tabs by spaces. This is disabled by default.
311+
# - tabs:
312+
# # Number of spaces to use for each tab. Default: 8, as specified by the
313+
# # Haskell report.
314+
# spaces: 8
315+
316+
# Remove trailing whitespace
317+
- trailing_whitespace: {}
318+
319+
# Squash multiple spaces between the left and right hand sides of some
320+
# elements into single spaces. Basically, this undoes the effect of
321+
# simple_align but is a bit less conservative.
322+
# - squash: {}
323+
324+
# A common setting is the number of columns (parts of) code will be wrapped
325+
# to. Different steps take this into account.
326+
#
327+
# Set this to null to disable all line wrapping.
328+
#
329+
# Default: 80.
330+
columns: 80
331+
332+
# By default, line endings are converted according to the OS. You can override
333+
# preferred format here.
334+
#
335+
# - native: Native newline format. CRLF on Windows, LF on other OSes.
336+
#
337+
# - lf: Convert to LF ("\n").
338+
#
339+
# - crlf: Convert to CRLF ("\r\n").
340+
#
341+
# Default: native.
342+
newline: native
343+
344+
# Sometimes, language extensions are specified in a cabal file or from the
345+
# command line instead of using language pragmas in the file. stylish-haskell
346+
# needs to be aware of these, so it can parse the file correctly.
347+
#
348+
# No language extensions are enabled by default.
349+
# language_extensions:
350+
# - TemplateHaskell
351+
# - QuasiQuotes
352+
353+
# Attempt to find the cabal file in ancestors of the current directory, and
354+
# parse options (currently only language extensions) from that.
355+
#
356+
# Default: true
357+
cabal: true

0 commit comments

Comments
 (0)