Skip to content

Commit 056bf91

Browse files
committed
Set up fourmolu as the formatter for 'troupec' (Haskell code)
1 parent 272b273 commit 056bf91

File tree

4 files changed

+108
-1
lines changed

4 files changed

+108
-1
lines changed

.github/workflows/fourmolu.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: fourmolu
2+
3+
on:
4+
push:
5+
branches: [ master, dev ]
6+
paths: [ '**.hs' ]
7+
pull_request_target:
8+
branches: [ master, dev ]
9+
paths: [ '**.hs' ]
10+
11+
jobs:
12+
format:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v5
16+
17+
- uses: haskell-actions/run-fourmolu@v9
18+
with:
19+
version: "0.17.0.0"
20+
follow-symbolic-links: false
21+
working-directory: "./compiler"

compiler/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ clean:
1111
rm -rf ../bin
1212
# If problems still persist after this, remove all GHC compilers in ~/.stack/programs/**/
1313

14+
# https://github.com/fourmolu/fourmolu
15+
format:
16+
fourmolu -i *.hs */*.hs
17+
18+
format/check:
19+
fourmolu --mode check *.hs */*.hs
20+
1421
ghci-irtester:
1522
stack ghci --main-is Troupe-compiler:exe:irtester --no-load
1623

compiler/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# PicoML-compiler
1+
# TroupeC: Troupe Compiler
2+
3+
## Formatting
4+
5+
The Haskell code is formatted with [`fourmolu`](https://github.com/fourmolu/fourmolu).

compiler/fourmolu.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Number of spaces per indentation step
2+
indentation: 4
3+
4+
# Max line length for automatic line breaking
5+
column-limit: none
6+
7+
# Styling of arrows in type signatures (choices: trailing, leading, or leading-args)
8+
function-arrows: trailing
9+
10+
# How to place commas in multi-line lists, records, etc. (choices: leading or trailing)
11+
comma-style: leading
12+
13+
# Styling of import/export lists (choices: leading, trailing, or diff-friendly)
14+
import-export-style: diff-friendly
15+
16+
# Rules for grouping import declarations
17+
import-grouping: legacy
18+
19+
# Whether to full-indent or half-indent 'where' bindings past the preceding body
20+
indent-wheres: false
21+
22+
# Whether to leave a space before an opening record brace
23+
record-brace-space: false
24+
25+
# Number of spaces between top-level declarations
26+
newlines-between-decls: 1
27+
28+
# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact)
29+
haddock-style: multi-line
30+
31+
# How to print module docstring
32+
haddock-style-module: null
33+
34+
# Styling of let blocks (choices: auto, inline, newline, or mixed)
35+
let-style: inline
36+
37+
# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space)
38+
in-style: right-align
39+
40+
# Whether keywords then and else should be indented or hanging off the current indentation.
41+
if-style: hanging
42+
43+
# Whether to put parentheses around a single constraint (choices: auto, always, or never)
44+
single-constraint-parens: always
45+
46+
# Whether to put parentheses around a single deriving class (choices: auto, always, or never)
47+
single-deriving-parens: always
48+
49+
# Whether to sort constraints
50+
sort-constraints: true
51+
52+
# Whether to sort derived classes
53+
sort-derived-classes: true
54+
55+
# Whether to sort deriving clauses
56+
sort-deriving-clauses: true
57+
58+
# Whether to place section operators (those that are infixr 0, such as $) in trailing position, continuing the expression indented below
59+
trailing-section-operators: true
60+
61+
# Output Unicode syntax (choices: detect, always, or never)
62+
unicode: never
63+
64+
# Give the programmer more choice on where to insert blank lines
65+
respectful: true
66+
67+
# Fixity information for operators
68+
fixities: []
69+
70+
# Module reexports Fourmolu should know about
71+
reexports: []
72+
73+
# Modules defined by the current Cabal package for import grouping
74+
local-modules: []
75+

0 commit comments

Comments
 (0)