Skip to content

Commit b75dd73

Browse files
committed
flake.nix: add fourmolu, purge stylish-haskell
1 parent 64ab9bd commit b75dd73

File tree

7 files changed

+30
-22
lines changed

7 files changed

+30
-22
lines changed

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,19 @@ and improvements are always welcome.
203203

204204
## Formatting the code
205205

206-
We use `stylish-haskell` 0.14.6.0 for Haskell code formatting.
206+
We use `fourmolu` 0.17.0.0 for Haskell code formatting.
207207

208208
Either enable editor integration or call the script used by CI itself:
209209

210210
```bash
211-
./scripts/ci/run-stylish.sh
211+
./scripts/ci/run-fourmolu.sh
212212
```
213213

214214
When using Nix, you can use the following command, which will build and use
215-
the right version of `stylish-haskell`.
215+
the right version of `fourmolu`.
216216

217217
```bash
218-
nix develop -c ./scripts/ci/run-stylish.sh
218+
nix develop -c ./scripts/ci/run-fourmolu.sh
219219
```
220220

221221
# Generating documentation and setting up hoogle

docs/website/contents/for-developers/StyleGuide.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ along with its context -- eg whatever is available in the GitHub PR interface.
3737
As long that rendering doesn't show that the PR spoils something like
3838
intentional alignment for example, then the PR has no style problems.
3939

40-
We run `stylish-haskell` as a requirement for merging. The specific
41-
configuration can be found [here][stylish-config].
40+
We run `fourmolu` as a requirement for merging. The specific
41+
configuration can be found [here][fourmolu-config].
4242

4343
## Guiding principles
4444

@@ -871,8 +871,8 @@ the rules below, it is good practice to update the code's style to match them.
871871

872872
*Why:* to avoid wasting horizontal screen space.
873873

874-
15. __Import lists__: we use `stylish-haskell` to automatically format import
875-
lists. See the [`.stylish-haskell.yaml` config][stylish-config].
874+
15. __Import lists__: we use `fourmolu` to automatically format import
875+
lists. See the [`fourmolu.yaml` config][fourmolu-config].
876876

877877
When importing modules from consensus and in particular modules from the
878878
same package, an import list and a qualifier can be omitted. For example,
@@ -882,8 +882,8 @@ the rules below, it is good practice to update the code's style to match them.
882882
When importing from other packages, we prefer to use either an import list
883883
or a qualifier.
884884

885-
16. __Export lists__: we use `stylish-haskell` to automatically format export
886-
lists. See the [`.stylish-haskell.yaml` config][stylish-config]. We format
885+
16. __Export lists__: we use `fourmolu` to automatically format export
886+
lists. See the [`fourmolu.yaml` config][fourmolu-config]. We format
887887
export lists in the following way:
888888

889889
```haskell
@@ -917,7 +917,7 @@ the rules below, it is good practice to update the code's style to match them.
917917
) where
918918
```
919919

920-
*Why:* this is consistent with how `stylish-haskell` formats it when
920+
*Why:* this is consistent with how `fourmolu` formats it when
921921
importing it.
922922

923923
When intentionally hiding the constructor of a datatype or newtype, we add
@@ -978,7 +978,7 @@ the rules below, it is good practice to update the code's style to match them.
978978
18. __Records__:
979979

980980
We purposefully discourage the use of `RecordWildCards`.
981-
981+
982982
For records we often use `NamedFieldPuns` to make it convenient to extract
983983
fields from the record. We use the following convention when naming fields
984984
to avoid duplicate record fields (we do not use `DuplicateRecordFields`):
@@ -1123,10 +1123,10 @@ the rules below, it is good practice to update the code's style to match them.
11231123
import Foo.C (fooC, ...)
11241124

11251125
```
1126-
1126+
11271127
*Why:* this leads to more changes to the export list, but makes it
11281128
absolutely clear where each identifier comes from.
1129-
1129+
11301130
## Guidelines
11311131

11321132
There are more general guidelines on how we write and structure code.
@@ -1204,4 +1204,4 @@ There are more general guidelines on how we write and structure code.
12041204
use that shared code in a test suite defined in another package. To avoid
12051205
this problem, we avoid sharing source directories in `cabal` files.
12061206

1207-
[stylish-config]: https://github.com/IntersectMBO/ouroboros-consensus/blob/master/.stylish-haskell.yaml
1207+
[fourmolu-config]: https://github.com/IntersectMBO/ouroboros-consensus/blob/master/fourmolu.yaml

fourmolu.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
indentation: 2
2+
column-limit: 100
3+
import-export-style: leading
4+
haddock-style: single-line
5+
single-constraint-parens: never
6+
single-deriving-parens: never

nix/formatting-linting.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let
2525
fi
2626
'';
2727
formattingLinting = {
28-
stylish = checkFormatting pkgs.stylish-haskell ../scripts/ci/run-stylish.sh;
28+
fourmolu = checkFormatting pkgs.fourmolu ../scripts/ci/run-fourmolu.sh;
2929
cabal-gild = checkFormatting pkgs.cabal-gild ../scripts/ci/run-cabal-gild.sh;
3030
nixpkgs-fmt = checkFormatting pkgs.nixpkgs-fmt ../scripts/ci/run-nixpkgs-fmt.sh;
3131
dos2unix = checkFormatting pkgs.dos2unix ../scripts/ci/run-dos2unix.sh;

nix/shell.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ hsPkgs.shellFor {
99
pkgs.cabal-docspec
1010
pkgs.fd
1111
pkgs.nixpkgs-fmt
12-
pkgs.stylish-haskell
1312
pkgs.dos2unix
1413
pkgs.cabal-gild
1514
pkgs.hlint
1615
pkgs.cabal-hoogle
1716
pkgs.ghcid
1817
pkgs.xrefcheck
18+
pkgs.fourmolu
1919

2020
# release management
2121
pkgs.scriv

nix/tools.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ in
3131
};
3232
};
3333

34-
stylish-haskell = tool "stylish-haskell" "0.14.6.0" { };
35-
3634
cabal-gild = tool "cabal-gild" "1.5.0.1" { };
3735

3836
hlint = tool "hlint" "3.8" { };
3937

4038
xrefcheck = tool "xrefcheck" "0.3.1" { };
4139

40+
fourmolu = tool "fourmolu" "0.18.0.0" {
41+
compiler-nix-name = "ghc98";
42+
};
43+
4244
haskellBuildUtils = prev.haskellBuildUtils.override {
4345
inherit (final.hsPkgs.args) compiler-nix-name;
4446
index-state = tool-index-state;

scripts/ci/run-stylish.sh renamed to scripts/ci/run-fourmolu.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
set -e
44

55
echo "The custom options for formatting this repo are:"
6-
stylish-haskell --version
7-
stylish-haskell --defaults | diff - ./.stylish-haskell.yaml | grep -E "^>.*[[:alnum:]]" | grep -v "#"
6+
fourmolu --version
7+
fourmolu --print-defaults | diff - ./fourmolu.yaml | grep -E "^>.*[[:alnum:]]" | grep -v "#"
88
printf "\nFormatting haskell files...\n"
99

1010
export LC_ALL=C.UTF-8
@@ -27,7 +27,7 @@ esac
2727

2828
$fdcmd --full-path "$path" \
2929
--extension hs \
30-
--exec-batch stylish-haskell -c .stylish-haskell.yaml -i
30+
--exec-batch fourmolu --config fourmolu.yaml -i
3131

3232
case "$(uname -s)" in
3333
MINGW*) git ls-files --eol | grep "w/crlf" | awk '{print $4}' | xargs dos2unix;;

0 commit comments

Comments
 (0)