git.iko.soy/typeable/pandoc
on master help sign in
Added 'make refactor' using hlint, stylish-haskell.
commit0edfbf1478950d645ece19ced0156771ba16ebb6 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 4 Mar 2017, 12:49 (10 years ago) parent17ce813
3 files changed+184−1
.stylish-haskell.yaml+171 Makefile+5−1 tools/refactor.sh+8
.stylish-haskell.yamlnew file+171
@@ -0,0 +1,171 @@
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+ # Align the right hand side of some elements. This is quite conservative
19+ # and only applies to statements where each element occupies a single
20+ # line.
21+ - simple_align:
22+ cases: true
23+ top_level_patterns: true
24+ records: true
25+
26+ # Import cleanup
27+ - imports:
28+ # There are different ways we can align names and lists.
29+ #
30+ # - global: Align the import names and import list throughout the entire
31+ # file.
32+ #
33+ # - file: Like global, but don't add padding when there are no qualified
34+ # imports in the file.
35+ #
36+ # - group: Only align the imports per group (a group is formed by adjacent
37+ # import lines).
38+ #
39+ # - none: Do not perform any alignment.
40+ #
41+ # Default: global.
42+ align: none
43+
44+ # Folowing options affect only import list alignment.
45+ #
46+ # List align has following options:
47+ #
48+ # - after_alias: Import list is aligned with end of import including
49+ # 'as' and 'hiding' keywords.
50+ #
51+ # > import qualified Data.List as List (concat, foldl, foldr, head,
52+ # > init, last, length)
53+ #
54+ # - with_alias: Import list is aligned with start of alias or hiding.
55+ #
56+ # > import qualified Data.List as List (concat, foldl, foldr, head,
57+ # > init, last, length)
58+ #
59+ # - new_line: Import list starts always on new line.
60+ #
61+ # > import qualified Data.List as List
62+ # > (concat, foldl, foldr, head, init, last, length)
63+ #
64+ # Default: after_alias
65+ list_align: after_alias
66+
67+ # Long list align style takes effect when import is too long. This is
68+ # determined by 'columns' setting.
69+ #
70+ # - inline: This option will put as much specs on same line as possible.
71+ #
72+ # - new_line: Import list will start on new line.
73+ #
74+ # - new_line_multiline: Import list will start on new line when it's
75+ # short enough to fit to single line. Otherwise it'll be multiline.
76+ #
77+ # - multiline: One line per import list entry.
78+ # Type with contructor list acts like single import.
79+ #
80+ # > import qualified Data.Map as M
81+ # > ( empty
82+ # > , singleton
83+ # > , ...
84+ # > , delete
85+ # > )
86+ #
87+ # Default: inline
88+ long_list_align: inline
89+
90+ # List padding determines indentation of import list on lines after import.
91+ # This option affects 'list_align' and 'long_list_align'.
92+ list_padding: 4
93+
94+ # Separate lists option affects formating of import list for type
95+ # or class. The only difference is single space between type and list
96+ # of constructors, selectors and class functions.
97+ #
98+ # - true: There is single space between Foldable type and list of it's
99+ # functions.
100+ #
101+ # > import Data.Foldable (Foldable (fold, foldl, foldMap))
102+ #
103+ # - false: There is no space between Foldable type and list of it's
104+ # functions.
105+ #
106+ # > import Data.Foldable (Foldable(fold, foldl, foldMap))
107+ #
108+ # Default: true
109+ separate_lists: true
110+
111+ # Language pragmas
112+ - language_pragmas:
113+ # We can generate different styles of language pragma lists.
114+ #
115+ # - vertical: Vertical-spaced language pragmas, one per line.
116+ #
117+ # - compact: A more compact style.
118+ #
119+ # - compact_line: Similar to compact, but wrap each line with
120+ # `{-#LANGUAGE #-}'.
121+ #
122+ # Default: vertical.
123+ style: vertical
124+
125+ # Align affects alignment of closing pragma brackets.
126+ #
127+ # - true: Brackets are aligned in same collumn.
128+ #
129+ # - false: Brackets are not aligned together. There is only one space
130+ # between actual import and closing bracket.
131+ #
132+ # Default: true
133+ align: true
134+
135+ # stylish-haskell can detect redundancy of some language pragmas. If this
136+ # is set to true, it will remove those redundant pragmas. Default: true.
137+ remove_redundant: true
138+
139+ # Replace tabs by spaces. This is disabled by default.
140+ # - tabs:
141+ # # Number of spaces to use for each tab. Default: 8, as specified by the
142+ # # Haskell report.
143+ # spaces: 8
144+
145+ # Remove trailing whitespace
146+ - trailing_whitespace: {}
147+
148+# A common setting is the number of columns (parts of) code will be wrapped
149+# to. Different steps take this into account. Default: 80.
150+columns: 80
151+
152+# By default, line endings are converted according to the OS. You can override
153+# preferred format here.
154+#
155+# - native: Native newline format. CRLF on Windows, LF on other OSes.
156+#
157+# - lf: Convert to LF ("\n").
158+#
159+# - crlf: Convert to CRLF ("\r\n").
160+#
161+# Default: native.
162+newline: native
163+
164+# Sometimes, language extensions are specified in a cabal file or from the
165+# command line instead of using language pragmas in the file. stylish-haskell
166+# needs to be aware of these, so it can parse the file correctly.
167+#
168+# No language extensions are enabled by default.
169+# language_extensions:
170+ # - TemplateHaskell
171+ # - QuasiQuotes
Makefile+5−1
@@ -1,5 +1,6 @@
11version?=$(shell grep '^Version:' pandoc.cabal | awk '{print $$2;}')
22pandoc=$(shell find dist -name pandoc -type f -exec ls -t {} \; | head -1)
3+sourcefiles=$(shell find pandoc.hs src test -name '*.hs')
34BRANCH?=master
45
56quick:
@@ -15,6 +16,9 @@ test:
1516bench:
1617 stack bench
1718
19+refactor:
20+ ./tools/refactor.sh $(sourcefiles)
21+
1822changes_github:
1923 pandoc --filter extract-changes.hs changelog -t markdown_github | sed -e 's/\\#/#/g' | pbcopy
2024
@@ -53,4 +57,4 @@ download_stats:
5357clean:
5458 stack clean
5559
56−.PHONY: deps quick full install clean test bench changes_github macospkg dist prof download_stats
60+.PHONY: deps quick full install clean test bench changes_github macospkg dist prof download_stats refactor
tools/refactor.shnew file+8
@@ -0,0 +1,8 @@
1+cppdir=`stack path --dist-dir`/build/autogen
2+for f in $*
3+do
4+ echo "Applying hlint --refactor to $f"
5+ hlint --refactor -i --cpp-file=$cppdir/cabal_macros.h $f >/dev/null
6+ echo "Applying stylish-haskell to $f"
7+ stylish-haskell -i $f | perl -ne 'if (/./) { print "\n" x $n, $_; $n = 0 } else { $n++ }' >/dev/null
8+done