1We aim for a format of Haskell code that minimizes the amount of changes
2necessary when modifying a line. For instance the indentation of any
3given fragment of code should not depend on the length of identifiers.
13Renaming the function requires changing all the lines to
22A preferred alternative is to format like
32We are grabbing some inspiration from
33[Elm](https://elm-lang.org/docs/style-guide)
35[Tweag's](https://github.com/tweag/guides/blob/master/style/Haskell.md)
38The following examples show how a program is formatted in
39multiple lines when the user introduces linebreaks. Otherwise,
40the programs would be written in one line.
73 :: (C1, C2, C3, C4, C5)
80 -> AnotherLongDataTypeName
90 :: (C1, C2, C3, C4, C5)
94 AnotherLongDataTypeName
95 AnotherLongDataTypeName2
96 AnotherLongDataTypeName3
98 -> AnotherLongDataTypeName4
110 if x then longFunctionName y else anotherLongFunctionName z
138There is a do block. Note the change of indentation in the
155 anotherLongFunctionName x z
158`if` expression with monadic blocks
162 longFunctionName1 x y
163 longFunctionName2 x y
165 anotherLongFunctionName1 x z
166 anotherLongFunctionName2 x z
179 Just w -> functionName x y w
180 Nothing -> functionName x y z
183Branches of `case` expression
187 longFunctionName x y w
189 anotherLongFunctionName x y z
196 (AnotherLongPattern y)
208The right-hand side of guards
214 anotherLongFunctionName x
227 anotherLongFunctionName x
230### Data type declarations
243TODO: GADTs, record syntax, type families
248{- When a comment is not preceded with elements on the same line,
249 they are indented as the elements in the enclosing AST node or
250 braces/parenthesis/brackets.
251 If it is between AST nodes, it is indented as the following
253 If the end-of-file follows, then indent to column 0.
256f = g {- When there are preceding elements, keep single-line comments in the same line. -}
259{- Multi-line comments can't be kept on the same line as @h = g@.
260 Otherwise, changing h or g would change the indentation of all
265 {- This comment always follows the R constructor -}
267 {- A comment not preceded by other elements -}
268 {- Another comment -}
279 -- indented the same as g
285data R = R {- This comment always follows the R constructor -}
286 { f1 :: T1, {- An inner comment -} {- Another inner comment -} f2 :: T2, f3 :: T3}
291 {- This comment always follows the R constructor -}
292 { f1 :: T1 {- An inner comment -} {- Another inner comment -}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list