git.iko.soy/rowtype-yoga/pose
on main help sign in
Add README info
commit111e094206864b9919895658f78765a2450eba42 authorMark Eibes <mark.eibes@gmail.com> dateFri 24 Sep 2021, 14:29 (5 years ago) parentdd81b6d
5 files changed+86−4
README.md+56−2 images/diff.png packages.dhall+1−2 packages/core/testfiles/golden/Issue5.purs+15 packages/core/testfiles/original/Issue5.purs+14
README.md+56−2
@@ -1,3 +1,57 @@
1−### POSE - a formatter for PureScript code
1+# POSE - a formatter for PureScript code
22
3−Find some instructions [here](https://pose.rowtype.yoga)
3+_Disclaimer_: You might want to use the [tidy](https://github.com/natefaubion/purescript-tidy) formatter instead.
4+
5+**The POSE project is in low maintenance mode.** This means that pull requests are very welcome but the original authors don't actively improve the code.
6+
7+## Try it out
8+
9+Try the formatter live and find some instructions [here](https://pose.rowtype.yoga)
10+
11+## Installation
12+
13+We hook into prettier to take care of a lot of the heavy lifting for us so let's install it and the plugin:
14+
15+```
16+npm install --save-dev prettier @rowtype-yoga/prettier-plugin-purescript
17+```
18+
19+We only want to format our own code so we modify .prettierignore:
20+
21+```
22+echo -e ".spago\noutput/" >> .prettierignore
23+```
24+
25+## Formatting
26+
27+If you use VSCode then you can simply turn on format on save and you're good to go, if you want to manually format some files here's an example:
28+
29+```
30+npx prettier --write src
31+```
32+
33+## Contributing
34+
35+The project is split in two subpackages:
36+
37+1. The core formatter in the `packages/core` folder
38+2. The prettier plugin in the `packages/prettier-plugin-purescript` folder
39+
40+To work on the formatter add a test in `packages/core/testfiles/original/` and run:
41+
42+```sh
43+spago -x exe.dhall test
44+```
45+
46+Then you should adjust the corresponding file in: `packages/core/testfiles/golden/` to what you expect the output to be and start making changes in `packages/core/src/Format.purs` until all tests pass.
47+
48+Run the tests often to get nice diffs:
49+![image of a diff](../../blob/master/images/diff.png)
50+
51+```
52+51 passing
53+1 failed
54+
55+1) Golden Tests formats Issue5.purs
56+ "The diff is saved here: file:///tmp/testfiles-golden-Issue5.purs-actual.html"
57+```
images/diff.pngnew file

Binary file not shown.

packages.dhall+1−2
@@ -188,8 +188,7 @@ in upstream
188188 , "tuples"
189189 , "typelevel-prelude"
190190 ]
191− , repo =
192− "https://github.com/natefaubion/purescript-language-cst-parser.git"
191+ , repo = "https://github.com/natefaubion/purescript-language-cst-parser.git"
193192 , version = "main"
194193 }
195194 with plumage =
packages/core/testfiles/golden/Issue5.pursnew file+15
@@ -0,0 +1,15 @@
1+module Issue.Five where
2+
3+getAdsInDateRangeWithKeywordPerParty ∷
4+ GraphQLClient → Record DateRangeAndQueryInput → Aff AggregatedAdsPerParty
5+getAdsInDateRangeWithKeywordPerParty client input = ado
6+ result ← client (Gql ∷ Gql AggSumPerParty) input
7+ in
8+ { afd: { all: result.afd_all.agg.sum, withKeyword: result.afd.agg.sum }
9+ , cdu: { all: result.cdu_all.agg.sum, withKeyword: result.cdu.agg.sum }
10+ , csu: { all: result.csu_all.agg.sum, withKeyword: result.csu.agg.sum }
11+ , fdp: { all: result.fdp_all.agg.sum, withKeyword: result.fdp.agg.sum }
12+ , gruene: { all: result.gruene_all.agg.sum, withKeyword: result.gruene.agg.sum }
13+ , linke: { all: result.linke_all.agg.sum, withKeyword: result.linke.agg.sum }
14+ , spd: { all: result.spd_all.agg.sum, withKeyword: result.spd.agg.sum }
15+ }
packages/core/testfiles/original/Issue5.pursnew file+14
@@ -0,0 +1,14 @@
1+module Issue.Five where
2+
3+getAdsInDateRangeWithKeywordPerParty ∷
4+ GraphQLClient → Record DateRangeAndQueryInput → Aff AggregatedAdsPerParty
5+getAdsInDateRangeWithKeywordPerParty client input = ado
6+ result ← client (Gql ∷ Gql AggSumPerParty) input
7+ in { afd: { all: result.afd_all.agg.sum, withKeyword: result.afd.agg.sum }
8+ , cdu: { all: result.cdu_all.agg.sum, withKeyword: result.cdu.agg.sum }
9+ , csu: { all: result.csu_all.agg.sum, withKeyword: result.csu.agg.sum }
10+ , fdp: { all: result.fdp_all.agg.sum, withKeyword: result.fdp.agg.sum }
11+ , gruene: { all: result.gruene_all.agg.sum, withKeyword: result.gruene.agg.sum }
12+ , linke: { all: result.linke_all.agg.sum, withKeyword: result.linke.agg.sum }
13+ , spd: { all: result.spd_all.agg.sum, withKeyword: result.spd.agg.sum }
14+ }