git.iko.soy/rowtype-yoga/purs-eval
on main help sign in
16 files changed+355−505
since splitsnapshots
unifiedsplit
.github/dependabot.yml+11 .github/workflows/release.yml+41 .github/workflows/test.yml+6−4 .github/workflows/todo.yml+14 .github/workflows/update-flake-lock.yml+30 .gitignore+1 .npmignore+6 CHANGELOG.md+63 README.md+10−3 flake.lock+67−395 flake.nix+63−30 package-lock.json+8−2 package.json+4−1 src/Main.purs+2−3 test/Main.purs+1−1 test/Test/Compiler/ServerMock.purs+28−66
.github/dependabot.ymlnew file+11
@@ -0,0 +1,11 @@
1+version: 2
2+updates:
3+ - package-ecosystem: "github-actions"
4+ directory: "/"
5+ schedule:
6+ interval: "weekly"
7+
8+ - package-ecosystem: "npm"
9+ directory: "/"
10+ schedule:
11+ interval: "weekly"
.github/workflows/release.ymlnew file+41
@@ -0,0 +1,41 @@
1+on:
2+ push:
3+ branches:
4+ - main
5+name: release
6+jobs:
7+ release:
8+ runs-on: ubuntu-latest
9+ steps:
10+ - uses: googleapis/release-please-action@v5
11+ id: release
12+ with:
13+ release-type: node
14+ - uses: actions/checkout@v7
15+ if: ${{ steps.release.outputs.release_created }}
16+ - uses: cachix/install-nix-action@v31
17+ if: ${{ steps.release.outputs.release_created }}
18+ with:
19+ extra_nix_config: |
20+ access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
21+ - uses: cachix/cachix-action@v17
22+ if: ${{ steps.release.outputs.release_created }}
23+ with:
24+ name: klarkc
25+ authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
26+ - run: |
27+ nix build .#npm
28+ mkdir -p dist
29+ cp result dist/purs-eval
30+ if: ${{ steps.release.outputs.release_created }}
31+ - uses: actions/setup-node@v7
32+ if: ${{ steps.release.outputs.release_created }}
33+ with:
34+ node-version: 18
35+ registry-url: 'https://registry.npmjs.org'
36+ - run: npm ci
37+ if: ${{ steps.release.outputs.release_created }}
38+ - run: npm publish
39+ if: ${{ steps.release.outputs.release_created }}
40+ env:
41+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
.github/workflows/test.yml+6−4
@@ -1,15 +1,17 @@
11name: "Test"
22on:
33 pull_request:
4− push:
54jobs:
65 tests:
76 runs-on: ubuntu-latest
87 steps:
9− - uses: actions/checkout@v3
10− - uses: cachix/install-nix-action@v18
8+ - uses: actions/checkout@v7
9+ - uses: cachix/install-nix-action@v31
1110 with:
1211 extra_nix_config: |
1312 access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
14− - run: nix build
13+ - uses: cachix/cachix-action@v17
14+ with:
15+ name: klarkc
16+ authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
1517 - run: nix flake check
.github/workflows/todo.ymlnew file+14
@@ -0,0 +1,14 @@
1+name: "Run TODO to Issue"
2+on:
3+ push:
4+ branches:
5+ - main
6+jobs:
7+ build:
8+ runs-on: "ubuntu-latest"
9+ steps:
10+ - uses: "actions/checkout@v7"
11+ - name: "TODO to Issue"
12+ uses: "alstr/todo-to-issue-action@v5"
13+ with:
14+ IDENTIFIERS: '[{"name": "TODO", "labels": ["help wanted"]}, {"name": "FIXME", "labels": ["bug"]}]'
.github/workflows/update-flake-lock.ymlnew file+30
@@ -0,0 +1,30 @@
1+name: update-flake-lock
2+on:
3+ workflow_dispatch: # allows manual triggering
4+ schedule:
5+ - cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
6+
7+jobs:
8+ lockfile:
9+ runs-on: ubuntu-latest
10+ steps:
11+ - name: Checkout repository
12+ uses: actions/checkout@v7
13+ - name: Install Nix
14+ uses: cachix/install-nix-action@v31
15+ with:
16+ extra_nix_config: |
17+ access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
18+ - uses: cachix/cachix-action@v17
19+ with:
20+ name: klarkc
21+ authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
22+ - name: Update flake.lock
23+ uses: DeterminateSystems/update-flake-lock@v29
24+ with:
25+ commit-msg: "build(deps): Bump flake.lock dependencies"
26+ pr-title: "Update flake.lock"
27+ pr-labels: |
28+ dependencies
29+ automated
30+ token: ${{ secrets.PAT_TOKEN }}
.gitignore+1
@@ -9,3 +9,4 @@
99/.psa*
1010/.spago
1111/result
12+/dist
.npmignorenew file+6
@@ -0,0 +1,6 @@
1+/.github
2+/flake.*
3+/test
4+/src
5+/test
6+/.psc-ide-port
CHANGELOG.mdnew file+63
@@ -0,0 +1,63 @@
1+# Changelog
2+
3+## [1.5.0](https://github.com/rowtype-yoga/purs-eval/compare/v1.4.1...v1.5.0) (2024-07-11)
4+
5+
6+### Features
7+
8+* upgrade purs-nix and change mock server to httpurple ([ddaad01](https://github.com/rowtype-yoga/purs-eval/commit/ddaad01eed68afa45f584c807ed577abc565c247))
9+
10+
11+### Bug Fixes
12+
13+* npm published version not running ([3f1a295](https://github.com/rowtype-yoga/purs-eval/commit/3f1a29567365000f57e6b2c9c54c55448c3a83c7))
14+
15+## [1.4.1](https://github.com/klarkc/purs-eval/compare/v1.4.0...v1.4.1) (2023-08-21)
16+
17+
18+### Bug Fixes
19+
20+* flake changes causing CI breakage ([d5d6085](https://github.com/klarkc/purs-eval/commit/d5d608561096f002d7004c1d54e0ae5aaebc67c8))
21+
22+## [1.4.0](https://github.com/klarkc/purs-eval/compare/v1.3.0...v1.4.0) (2023-08-21)
23+
24+
25+### Features
26+
27+* add LSP to flake ([bb9f0e7](https://github.com/klarkc/purs-eval/commit/bb9f0e7b57980e7972c4ee454227351c599b5d35))
28+
29+
30+### Bug Fixes
31+
32+* library API change ([b5acee9](https://github.com/klarkc/purs-eval/commit/b5acee96178b09f8c0505098a6e29171e27377a0))
33+* npmlock2nix refusing to build ([3270052](https://github.com/klarkc/purs-eval/commit/3270052badb0fd9f1fa9c2166cec6cc2a4db4a75))
34+* purs-nix API changes ([025f93e](https://github.com/klarkc/purs-eval/commit/025f93e75b82009d5d51061937093f052dbbea9e))
35+
36+## [1.3.0](https://github.com/klarkc/purs-eval/compare/v1.2.0...v1.3.0) (2022-12-17)
37+
38+
39+### Features
40+
41+* remove deprecated code ([bd857f1](https://github.com/klarkc/purs-eval/commit/bd857f17d0bae24376f734373c39682290acd1ff))
42+
43+## 1.2.0 (2022-11-02)
44+
45+
46+### Features
47+
48+* add capabilities and launch the compiler ([c5609ef](https://github.com/klarkc/purs-eval/commit/c5609ef15b5c55a994886d5b609a617aabb6aa58))
49+* add compile ([bcf123b](https://github.com/klarkc/purs-eval/commit/bcf123b4367614a2d7630c9fcb6c7a583ee0cf7b))
50+* add import rename ([981f0da](https://github.com/klarkc/purs-eval/commit/981f0da6a9154826a6c2518c87505e224c67a442))
51+* add main append ([69684e1](https://github.com/klarkc/purs-eval/commit/69684e1c82808c68218f0359a2d870ced0b54b4b))
52+* add purs-eval npm publication ([a3fe337](https://github.com/klarkc/purs-eval/commit/a3fe33766551755e228bbd8ae7f8199452f500e4))
53+* add stream lib ([f2fb650](https://github.com/klarkc/purs-eval/commit/f2fb650818f424b081f6051ef2ea4bebb09af75c))
54+* add try pparsing ([3e10f28](https://github.com/klarkc/purs-eval/commit/3e10f2827355cccb9900204ae16fdeaa8fb56748))
55+* bootstrap purs-nix project ([ba47715](https://github.com/klarkc/purs-eval/commit/ba477157cf817a36f89944b9dfeccac3483f0f4b))
56+* Initial commit ([6c4e7d1](https://github.com/klarkc/purs-eval/commit/6c4e7d17bc3a932b872076b8cbc31f7f9e83b981))
57+
58+
59+### Bug Fixes
60+
61+* add missing xhr ffi dep ([6a0965b](https://github.com/klarkc/purs-eval/commit/6a0965b236deca5d9ec975febbf5b0b0da7f76bd))
62+* incorrect purescript URL ([736ee61](https://github.com/klarkc/purs-eval/commit/736ee612a149e291e0606ae70210ab51c8a8a3f8))
63+* npm bin not being found ([fa97556](https://github.com/klarkc/purs-eval/commit/fa97556f4d207b31d06e499e446068e882b98697))
README.md+10−3
@@ -1,13 +1,20 @@
11# purs-eval
2−A simple PureScript expression evaluation tool
2+A simple PureScript expression evaluation tool. It uses [try.purescript.org](https://try.purescript.org) as a compilation backend; for this reason, it currently does not support embedding local files or modules.
33
44## Usage
55
66```bash
7+EXAMPLE="module Main where\nimport Effect.Console (log)\nmain = log \"hello from PS\""
78
89# With npm
9−echo -e "module Main where\nimport Effect.Console (log)\nmain = log \"hello\"" | npx purs-eval
10+echo -e $EXAMPLE | npx purs-eval
1011
1112# With nix
12−echo -e "module Main where\nimport Effect.Console (log)\nmain = log \"hello\"" | nix run github:klarkc/purs-eval
13+echo -e $EXAMPLE | nix run github:rowtype-yoga/purs-eval
14+
15+# Pipe node (>v18)
16+echo -e $EXAMPLE | nix run github:rowtype-yoga/purs-eval | nix run nixpkgs#nodejs -- --experimental-network-imports --input-type module
17+
18+# or with npx
19+echo -e $EXAMPLE | npx purs-eval | node --experimental-network-imports --input-type module
1320```
flake.lock+67−395
@@ -1,55 +1,13 @@
11{
22 "nodes": {
3− "deadnix": {
4− "inputs": {
5− "fenix": "fenix",
6− "naersk": "naersk",
7− "nixpkgs": "nixpkgs_4",
8− "utils": "utils"
9− },
10− "locked": {
11− "lastModified": 1655647809,
12− "narHash": "sha256-npyHYIJW7HyGIFpCZZK+t5JM/v2LsyFhAGJxX1DXO7E=",
13− "owner": "astro",
14− "repo": "deadnix",
15− "rev": "83c42cc64d190ecb72f5929eab0f64fe88e25dc4",
16− "type": "github"
17− },
18− "original": {
19− "owner": "astro",
20− "repo": "deadnix",
21− "type": "github"
22− }
23− },
24− "deadnix_2": {
25− "inputs": {
26− "fenix": "fenix_2",
27− "naersk": "naersk_2",
28− "nixpkgs": "nixpkgs_8",
29− "utils": "utils_2"
30− },
31− "locked": {
32− "lastModified": 1656370114,
33− "narHash": "sha256-XBbSWeBuF6Ck0jc634yAp2hjPXWM2JyRDPCdK0dh3w4=",
34− "owner": "astro",
35− "repo": "deadnix",
36− "rev": "9f450f7250ad7680cb5f12ce5985cc18496c2d5f",
37− "type": "github"
38− },
39− "original": {
40− "owner": "astro",
41− "repo": "deadnix",
42− "type": "github"
43− }
44− },
453 "docs-search": {
464 "flake": false,
475 "locked": {
48− "lastModified": 1661787609,
49− "narHash": "sha256-jgOl8PKisRmcaHOya3HzArI3eKjVErx+XIBGminh9Zk=",
6+ "lastModified": 1675992564,
7+ "narHash": "sha256-Tk9VSogFHXtXe9O9vuCEfM/PV/S7plMIO0I++fCZn7U=",
508 "owner": "purs-nix",
519 "repo": "purescript-docs-search",
52− "rev": "4620575e21886fcbf516d0b43910ba4ead2a60d0",
10+ "rev": "35822b1d6ce65b1a07f80dd9e2caf15c3ee83e2c",
5311 "type": "github"
5412 },
5513 "original": {
@@ -58,68 +16,22 @@
5816 "type": "github"
5917 }
6018 },
61− "fenix": {
62− "inputs": {
63− "nixpkgs": "nixpkgs_2",
64− "rust-analyzer-src": "rust-analyzer-src"
65− },
66− "locked": {
67− "lastModified": 1655533500,
68− "narHash": "sha256-qJJmLVoMYfDLywI9MNL7sb0W/GsKQF9HDatdHm1tSl0=",
69− "owner": "nix-community",
70− "repo": "fenix",
71− "rev": "b6630603af13df17d0dd4df8629e9a24e6ba0fbd",
72− "type": "github"
73− },
74− "original": {
75− "owner": "nix-community",
76− "repo": "fenix",
77− "type": "github"
78− }
79− },
80− "fenix_2": {
81− "inputs": {
82− "nixpkgs": "nixpkgs_6",
83− "rust-analyzer-src": "rust-analyzer-src_2"
84− },
85− "locked": {
86− "lastModified": 1655533500,
87− "narHash": "sha256-qJJmLVoMYfDLywI9MNL7sb0W/GsKQF9HDatdHm1tSl0=",
88− "owner": "nix-community",
89− "repo": "fenix",
90− "rev": "b6630603af13df17d0dd4df8629e9a24e6ba0fbd",
91− "type": "github"
92− },
93− "original": {
94− "owner": "nix-community",
95− "repo": "fenix",
96− "type": "github"
97− }
98− },
99− "fenix_3": {
100− "inputs": {
101− "nixpkgs": [
102− "purs-nix",
103− "statix",
104− "nixpkgs"
105− ],
106− "rust-analyzer-src": "rust-analyzer-src_3"
107− },
19+ "flake-utils": {
10820 "locked": {
109− "lastModified": 1645251813,
110− "narHash": "sha256-cQ66tGjnZclBCS3nD26mZ5fUH+3/HnysGffBiWXUSHk=",
111− "owner": "nix-community",
112− "repo": "fenix",
113− "rev": "9892337b588c38ec59466a1c89befce464aae7f8",
21+ "lastModified": 1644229661,
22+ "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
23+ "owner": "numtide",
24+ "repo": "flake-utils",
25+ "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
11426 "type": "github"
11527 },
11628 "original": {
117− "owner": "nix-community",
118− "repo": "fenix",
29+ "owner": "numtide",
30+ "repo": "flake-utils",
11931 "type": "github"
12032 }
12133 },
122− "flake-utils": {
34+ "flake-utils_2": {
12335 "locked": {
12436 "lastModified": 1618217525,
12537 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
@@ -134,7 +46,7 @@
13446 "type": "github"
13547 }
13648 },
137− "flake-utils_2": {
49+ "flake-utils_3": {
13850 "locked": {
13951 "lastModified": 1618217525,
14052 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
@@ -149,7 +61,7 @@
14961 "type": "github"
15062 }
15163 },
152− "flake-utils_3": {
64+ "flake-utils_4": {
15365 "locked": {
15466 "lastModified": 1618217525,
15567 "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=",
@@ -179,25 +91,41 @@
17991 "type": "github"
18092 }
18193 },
182− "gitignore": {
94+ "httpurple-argonaut": {
95+ "flake": false,
96+ "locked": {
97+ "lastModified": 1655138308,
98+ "narHash": "sha256-tWTgc2gERJLkv+XzK4HtqJJbqvw10svVu1cmXFADtls=",
99+ "owner": "sigma-andex",
100+ "repo": "purescript-httpurple-argonaut",
101+ "rev": "3187fba4fe0682849b4acbf215e6a6fc1f6493de",
102+ "type": "github"
103+ },
104+ "original": {
105+ "owner": "sigma-andex",
106+ "repo": "purescript-httpurple-argonaut",
107+ "type": "github"
108+ }
109+ },
110+ "lint-utils": {
183111 "inputs": {
112+ "flake-utils": "flake-utils",
184113 "nixpkgs": [
185114 "purs-nix",
186− "statix",
187115 "nixpkgs"
188116 ]
189117 },
190118 "locked": {
191− "lastModified": 1635165013,
192− "narHash": "sha256-o/BdVjNwcB6jOmzZjOH703BesSkkS5O7ej3xhyO8hAY=",
193− "owner": "hercules-ci",
194− "repo": "gitignore.nix",
195− "rev": "5b9e0ff9d3b551234b4f3eb3983744fa354b17f1",
119+ "lastModified": 1707777931,
120+ "narHash": "sha256-PsPb5xMBZ9dPDP04o9vqKEUIEG80Z84/74fPuOMs0ZI=",
121+ "owner": "homotopic",
122+ "repo": "lint-utils",
123+ "rev": "5f11e3e51d8f1aa4ed62a89e90f05953931e105a",
196124 "type": "github"
197125 },
198126 "original": {
199− "owner": "hercules-ci",
200− "repo": "gitignore.nix",
127+ "owner": "homotopic",
128+ "repo": "lint-utils",
201129 "type": "github"
202130 }
203131 },
@@ -233,49 +161,13 @@
233161 "type": "github"
234162 }
235163 },
236− "naersk": {
237− "inputs": {
238− "nixpkgs": "nixpkgs_3"
239− },
240− "locked": {
241− "lastModified": 1655042882,
242− "narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=",
243− "owner": "nix-community",
244− "repo": "naersk",
245− "rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f",
246− "type": "github"
247− },
248− "original": {
249− "owner": "nix-community",
250− "repo": "naersk",
251− "type": "github"
252− }
253− },
254− "naersk_2": {
255− "inputs": {
256− "nixpkgs": "nixpkgs_7"
257− },
258− "locked": {
259− "lastModified": 1655042882,
260− "narHash": "sha256-9BX8Fuez5YJlN7cdPO63InoyBy7dm3VlJkkmTt6fS1A=",
261− "owner": "nix-community",
262− "repo": "naersk",
263− "rev": "cddffb5aa211f50c4b8750adbec0bbbdfb26bb9f",
264− "type": "github"
265− },
266− "original": {
267− "owner": "nix-community",
268− "repo": "naersk",
269− "type": "github"
270− }
271− },
272164 "nixpkgs": {
273165 "locked": {
274− "lastModified": 1666926733,
275− "narHash": "sha256-+gYfOEnQVISPDRNoWm2VJD5OEuTUySt48RchLpvm61o=",
166+ "lastModified": 1704161960,
167+ "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=",
276168 "owner": "NixOS",
277169 "repo": "nixpkgs",
278− "rev": "f44ba1be526c8da9e79a5759feca2365204003f6",
170+ "rev": "63143ac2c9186be6d9da6035fa22620018c85932",
279171 "type": "github"
280172 },
281173 "original": {
@@ -285,127 +177,7 @@
285177 "type": "github"
286178 }
287179 },
288− "nixpkgs_10": {
289− "locked": {
290− "lastModified": 1645013224,
291− "narHash": "sha256-b7OEC8vwzJv3rsz9pwnTX2LQDkeOWz2DbKypkVvNHXc=",
292− "owner": "nixos",
293− "repo": "nixpkgs",
294− "rev": "b66b39216b1fef2d8c33cc7a5c72d8da80b79970",
295− "type": "github"
296− },
297− "original": {
298− "owner": "nixos",
299− "ref": "nixpkgs-unstable",
300− "repo": "nixpkgs",
301− "type": "github"
302− }
303− },
304180 "nixpkgs_2": {
305− "locked": {
306− "lastModified": 1655400192,
307− "narHash": "sha256-49OBVVRgb9H/PSmNT9W61+NRdDbuSJVuDDflwXlaUKU=",
308− "owner": "nixos",
309− "repo": "nixpkgs",
310− "rev": "3d7435c638baffaa826b85459df0fff47f12317d",
311− "type": "github"
312− },
313− "original": {
314− "owner": "nixos",
315− "ref": "nixos-unstable",
316− "repo": "nixpkgs",
317− "type": "github"
318− }
319− },
320− "nixpkgs_3": {
321− "locked": {
322− "lastModified": 1655481042,
323− "narHash": "sha256-XHbcywq2vIQ5CeH1OK3TN793jkiNAAZsSctS1PFgseo=",
324− "owner": "NixOS",
325− "repo": "nixpkgs",
326− "rev": "103a4c0ae46afa9cf008c30744175315ca38e9f9",
327− "type": "github"
328− },
329− "original": {
330− "id": "nixpkgs",
331− "type": "indirect"
332− }
333− },
334− "nixpkgs_4": {
335− "locked": {
336− "lastModified": 1655481042,
337− "narHash": "sha256-XHbcywq2vIQ5CeH1OK3TN793jkiNAAZsSctS1PFgseo=",
338− "owner": "NixOS",
339− "repo": "nixpkgs",
340− "rev": "103a4c0ae46afa9cf008c30744175315ca38e9f9",
341− "type": "github"
342− },
343− "original": {
344− "id": "nixpkgs",
345− "type": "indirect"
346− }
347− },
348− "nixpkgs_5": {
349− "locked": {
350− "lastModified": 1646506091,
351− "narHash": "sha256-sWNAJE2m+HOh1jtXlHcnhxsj6/sXrHgbqVNcVRlveK4=",
352− "owner": "NixOS",
353− "repo": "nixpkgs",
354− "rev": "3e644bd62489b516292c816f70bf0052c693b3c7",
355− "type": "github"
356− },
357− "original": {
358− "owner": "NixOS",
359− "ref": "nixpkgs-unstable",
360− "repo": "nixpkgs",
361− "type": "github"
362− }
363− },
364− "nixpkgs_6": {
365− "locked": {
366− "lastModified": 1655400192,
367− "narHash": "sha256-49OBVVRgb9H/PSmNT9W61+NRdDbuSJVuDDflwXlaUKU=",
368− "owner": "nixos",
369− "repo": "nixpkgs",
370− "rev": "3d7435c638baffaa826b85459df0fff47f12317d",
371− "type": "github"
372− },
373− "original": {
374− "owner": "nixos",
375− "ref": "nixos-unstable",
376− "repo": "nixpkgs",
377− "type": "github"
378− }
379− },
380− "nixpkgs_7": {
381− "locked": {
382− "lastModified": 1655481042,
383− "narHash": "sha256-XHbcywq2vIQ5CeH1OK3TN793jkiNAAZsSctS1PFgseo=",
384− "owner": "NixOS",
385− "repo": "nixpkgs",
386− "rev": "103a4c0ae46afa9cf008c30744175315ca38e9f9",
387− "type": "github"
388− },
389− "original": {
390− "id": "nixpkgs",
391− "type": "indirect"
392− }
393− },
394− "nixpkgs_8": {
395− "locked": {
396− "lastModified": 1655481042,
397− "narHash": "sha256-XHbcywq2vIQ5CeH1OK3TN793jkiNAAZsSctS1PFgseo=",
398− "owner": "NixOS",
399− "repo": "nixpkgs",
400− "rev": "103a4c0ae46afa9cf008c30744175315ca38e9f9",
401− "type": "github"
402− },
403− "original": {
404− "id": "nixpkgs",
405− "type": "indirect"
406− }
407− },
408− "nixpkgs_9": {
409181 "locked": {
410182 "lastModified": 1656549732,
411183 "narHash": "sha256-eILutFZGjfk2bEzfim8S/qyYc//0S1KsCeO+OWbtoR0=",
@@ -424,11 +196,11 @@
424196 "npmlock2nix": {
425197 "flake": false,
426198 "locked": {
427− "lastModified": 1666460237,
428− "narHash": "sha256-HME6rnysvCwUVtH+BDWDGahmweMaLgD2wqHeRuGp6QI=",
199+ "lastModified": 1673447413,
200+ "narHash": "sha256-sJM82Sj8yfQYs9axEmGZ9Evzdv/kDcI9sddqJ45frrU=",
429201 "owner": "nix-community",
430202 "repo": "npmlock2nix",
431− "rev": "eeed152290ec2425f96c5e74e469c40b621e1468",
203+ "rev": "9197bbf397d76059a76310523d45df10d2e4ca81",
432204 "type": "github"
433205 },
434206 "original": {
@@ -454,17 +226,16 @@
454226 },
455227 "ps-tools": {
456228 "inputs": {
457− "deadnix": "deadnix_2",
458229 "make-shell": "make-shell_2",
459− "nixpkgs": "nixpkgs_9",
460− "utils": "utils_3"
230+ "nixpkgs": "nixpkgs_2",
231+ "utils": "utils"
461232 },
462233 "locked": {
463− "lastModified": 1658374818,
464− "narHash": "sha256-WxbQ/BR4Ep8tBbaOikXechspyZlvwfL5XNmRNEnaOFo=",
234+ "lastModified": 1704567308,
235+ "narHash": "sha256-WbFPIkKLtyQOPBUjintckKIYnfs7MvIbmfVsLRSAPlc=",
465236 "owner": "purs-nix",
466237 "repo": "purescript-tools",
467− "rev": "c0f887f60ea2331dfdc5b0e8be2e732976887345",
238+ "rev": "ac626313141cbee78f06eb3c5e90359f695aef9b",
468239 "type": "github"
469240 },
470241 "original": {
@@ -475,147 +246,48 @@
475246 },
476247 "purs-nix": {
477248 "inputs": {
478− "deadnix": "deadnix",
479249 "docs-search": "docs-search",
480250 "get-flake": "get-flake",
251+ "lint-utils": "lint-utils",
481252 "make-shell": "make-shell",
482− "nixpkgs": "nixpkgs_5",
253+ "nixpkgs": "nixpkgs",
483254 "parsec": "parsec",
484255 "ps-tools": "ps-tools",
485− "statix": "statix",
486− "utils": "utils_4"
256+ "utils": "utils_2"
487257 },
488258 "locked": {
489− "lastModified": 1666124404,
490− "narHash": "sha256-aArvsmkMc+LF2wEdLryiX/kqzMjtLsbcniIuSfFKgxg=",
259+ "lastModified": 1711996073,
260+ "narHash": "sha256-NDV8q9qtpKjHgIcMVBgdNqEfhpfK1d19rHYNa7yq0Qs=",
491261 "owner": "purs-nix",
492262 "repo": "purs-nix",
493− "rev": "66427405d2a3e0c2491646a6efc1716ce3731f3d",
263+ "rev": "8caa40f7fe69b9fcd05baae04c4ec9eb43953e2e",
494264 "type": "github"
495265 },
496266 "original": {
497267 "owner": "purs-nix",
498− "ref": "ps-0.15",
499268 "repo": "purs-nix",
500269 "type": "github"
501270 }
502271 },
503272 "root": {
504273 "inputs": {
505− "nixpkgs": "nixpkgs",
274+ "httpurple-argonaut": "httpurple-argonaut",
275+ "nixpkgs": [
276+ "purs-nix",
277+ "nixpkgs"
278+ ],
506279 "npmlock2nix": "npmlock2nix",
507280 "ps-tools": [
508281 "purs-nix",
509282 "ps-tools"
510283 ],
511284 "purs-nix": "purs-nix",
512− "utils": "utils_5"
513− }
514− },
515− "rust-analyzer-src": {
516− "flake": false,
517− "locked": {
518− "lastModified": 1655507737,
519− "narHash": "sha256-o+AqNsjL6o2RHh4InZHQVpkmqg570YFJL4Db8mKq+fs=",
520− "owner": "rust-lang",
521− "repo": "rust-analyzer",
522− "rev": "12dd81092e37df28b7a3591cae9675e668927198",
523− "type": "github"
524− },
525− "original": {
526− "owner": "rust-lang",
527− "ref": "nightly",
528− "repo": "rust-analyzer",
529− "type": "github"
530− }
531− },
532− "rust-analyzer-src_2": {
533− "flake": false,
534− "locked": {
535− "lastModified": 1655507737,
536− "narHash": "sha256-o+AqNsjL6o2RHh4InZHQVpkmqg570YFJL4Db8mKq+fs=",
537− "owner": "rust-lang",
538− "repo": "rust-analyzer",
539− "rev": "12dd81092e37df28b7a3591cae9675e668927198",
540− "type": "github"
541− },
542− "original": {
543− "owner": "rust-lang",
544− "ref": "nightly",
545− "repo": "rust-analyzer",
546− "type": "github"
547− }
548− },
549− "rust-analyzer-src_3": {
550− "flake": false,
551− "locked": {
552− "lastModified": 1645205556,
553− "narHash": "sha256-e4lZW3qRyOEJ+vLKFQP7m2Dxh5P44NrnekZYLxlucww=",
554− "owner": "rust-analyzer",
555− "repo": "rust-analyzer",
556− "rev": "acf5874b39f3dc5262317a6074d9fc7285081161",
557− "type": "github"
558− },
559− "original": {
560− "owner": "rust-analyzer",
561− "ref": "nightly",
562− "repo": "rust-analyzer",
563− "type": "github"
564− }
565− },
566− "statix": {
567− "inputs": {
568− "fenix": "fenix_3",
569− "gitignore": "gitignore",
570− "nixpkgs": "nixpkgs_10"
571− },
572− "locked": {
573− "lastModified": 1657460333,
574− "narHash": "sha256-5o6zMBASEsGKtjKDb3SizJnN9A7qpOcbzWBXsacfMyc=",
575− "owner": "nerdypepper",
576− "repo": "statix",
577− "rev": "6422c959d365dee2fda5eda8858fefad31f17b25",
578− "type": "github"
579− },
580− "original": {
581− "owner": "nerdypepper",
582− "repo": "statix",
583− "type": "github"
285+ "utils": "utils_3"
584286 }
585287 },
586288 "utils": {
587− "locked": {
588− "lastModified": 1653893745,
589− "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
590− "owner": "numtide",
591− "repo": "flake-utils",
592− "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
593− "type": "github"
594− },
595− "original": {
596− "owner": "numtide",
597− "repo": "flake-utils",
598− "type": "github"
599− }
600− },
601− "utils_2": {
602− "locked": {
603− "lastModified": 1653893745,
604− "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
605− "owner": "numtide",
606− "repo": "flake-utils",
607− "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
608− "type": "github"
609− },
610− "original": {
611− "owner": "numtide",
612− "repo": "flake-utils",
613− "type": "github"
614− }
615− },
616− "utils_3": {
617289 "inputs": {
618− "flake-utils": "flake-utils"
290+ "flake-utils": "flake-utils_2"
619291 },
620292 "locked": {
621293 "lastModified": 1656044990,
@@ -632,9 +304,9 @@
632304 "type": "github"
633305 }
634306 },
635− "utils_4": {
307+ "utils_2": {
636308 "inputs": {
637− "flake-utils": "flake-utils_2"
309+ "flake-utils": "flake-utils_3"
638310 },
639311 "locked": {
640312 "lastModified": 1656044990,
@@ -651,9 +323,9 @@
651323 "type": "github"
652324 }
653325 },
654− "utils_5": {
326+ "utils_3": {
655327 "inputs": {
656− "flake-utils": "flake-utils_3"
328+ "flake-utils": "flake-utils_4"
657329 },
658330 "locked": {
659331 "lastModified": 1658606827,
flake.nix+63−30
@@ -1,77 +1,110 @@
11{
22 inputs =
33 {
4− nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5− npmlock2nix.url = "github:nix-community/npmlock2nix";
6− npmlock2nix.flake = false;
7− ps-tools.follows = "purs-nix/ps-tools";
8− purs-nix.url = "github:purs-nix/purs-nix/ps-0.15";
4+ purs-nix.url = "github:purs-nix/purs-nix";
5+ nixpkgs.follows = "purs-nix/nixpkgs";
96 utils.url = "github:ursi/flake-utils";
7+ ps-tools.follows = "purs-nix/ps-tools";
8+ npmlock2nix = {
9+ url = "github:nix-community/npmlock2nix";
10+ flake = false;
11+ };
12+ httpurple-argonaut = {
13+ url = "github:sigma-andex/purescript-httpurple-argonaut";
14+ flake = false;
15+ };
1016 };
1117
12− outputs = { utils, ... }@inputs:
18+ outputs = { self, utils, ... }@inputs:
1319 utils.apply-systems
1420 {
1521 inherit inputs;
1622 # Limited by ps-tools
1723 systems = [ "x86_64-linux" "x86_64-darwin" ];
1824 }
19− ({ pkgs, system, ... }:
25+ ({ pkgs, system, ... }@ctx:
2026 let
27+ inherit (pkgs) nodejs;
2128 npm = import inputs.npmlock2nix { inherit pkgs; };
22− ps-tools = inputs.ps-tools.legacyPackages.${system};
29+ node_modules = npm.v2.node_modules { src = ./.; inherit nodejs; } + /node_modules;
30+ inherit (ctx.ps-tools) purescript purs-tidy purescript-language-server;
2331 purs-nix = inputs.purs-nix { inherit system; };
32+ affjax-node_ = pkgs.lib.recursiveUpdate purs-nix.ps-pkgs.affjax-node {
33+ purs-nix-info.foreign."Affjax.Node" = { inherit node_modules; };
34+ };
35+ # TODO use httpurple-argonaut from official index
36+ httpurple-argonaut_ = purs-nix.build
37+ {
38+ name = "httpurple-argonaut";
39+ src.path = inputs.httpurple-argonaut;
40+ info.dependencies = [ "argonaut" "console" "effect" "either" "httpurple" "prelude"];
41+ };
2442 ps =
2543 purs-nix.purs
2644 {
2745 dir = ./.;
28−
2946 dependencies =
3047 with purs-nix.ps-pkgs;
3148 [
3249 prelude
3350 debug
3451 aff
35− affjax-node
52+ affjax-node_
3653 argonaut-codecs
3754 argonaut-generic
3855 effect
39− httpure
40− node-buffer
41− node-process
42− node-streams-aff
56+ httpurple
57+ httpurple-argonaut_
4358 test-unit
4459 parsing
4560 ];
46−
47− foreign."Affjax.Node".node_modules = npm.node_modules { src = ./.; } + /node_modules;
48−
61+ inherit purescript nodejs;
4962 };
63+ name = "purs-eval";
5064 in
65+ with ps;
5166 rec {
52− apps.default = {
53− type = "app";
54− program = "${packages.default}/bin/purs-eval";
55− };
67+ apps.default =
68+ {
69+ type = "app";
70+ program = "${packages.default}/bin/${name}";
71+ };
5672
57− packages = with ps.modules.Main; {
58− default = app { name = "purs-eval"; };
59− bundle = bundle { };
60− output = output { };
61− };
73+ packages =
74+ {
75+ default = app { inherit name; };
76+ # npm version does not publish a nix-store path
77+ npm = pkgs.runCommand
78+ "purs-eval-npm"
79+ {}
80+ ''
81+ echo "#!/usr/bin/env node" > $out
82+ tail -n +2 ${packages.default}/bin/purs-eval >> $out
83+ '';
84+ };
6285
63−
64− checks.test = ps.test.check { };
86+ checks.test = test.check { };
6587
6688 devShells.default = pkgs.mkShell {
6789 packages = with pkgs; [
6890 nodejs
6991 (ps.command { })
70− ps-tools.for-0_15.purescript-language-server
92+ purescript-language-server
93+ purs-tidy
94+ purescript
7195 purs-nix.esbuild
72− purs-nix.purescript
7396 ];
7497 };
7598 }
7699 );
100+
101+ nixConfig = {
102+ extra-experimental-features = "nix-command flakes";
103+ extra-substituters = [
104+ "https://klarkc.cachix.org"
105+ ];
106+ extra-trusted-public-keys = [
107+ "klarkc.cachix.org-1:R+z+m4Cq0hMgfZ7AQ42WRpGuHJumLLx3k0XhwpNFq9U="
108+ ];
109+ };
77110}
package-lock.json+8−2
@@ -4,9 +4,14 @@
44 "requires": true,
55 "packages": {
66 "": {
7+ "name": "purs-eval",
8+ "bin": {
9+ "purs-eval": "result/bin/purs-eval"
10+ },
711 "devDependencies": {
812 "xhr2": "^0.2.1"
9− }
13+ },
14+ "version": "1.5.0"
1015 },
1116 "node_modules/xhr2": {
1217 "version": "0.2.1",
@@ -25,5 +30,6 @@
2530 "integrity": "sha512-sID0rrVCqkVNUn8t6xuv9+6FViXjUVXq8H5rWOH2rz9fDNQEd4g0EA2XlcEdJXRz5BMEn4O1pJFdT+z4YHhoWw==",
2631 "dev": true
2732 }
28− }
33+ },
34+ "version": "1.5.0"
2935}
package.json+4−1
@@ -1,5 +1,8 @@
11{
2+ "name": "purs-eval",
3+ "bin": "dist/purs-eval",
24 "devDependencies": {
35 "xhr2": "^0.2.1"
4− }
6+ },
7+ "version": "1.5.0"
58}
src/Main.purs+2−3
@@ -1,7 +1,6 @@
11module Main (main) where
22
33import Prelude (Unit, bind, discard)
4−import Data.Tuple (Tuple (Tuple))
54import Effect (Effect)
65import Effect.Aff (launchAff_)
76import Node.Process (stdin, stdout)
@@ -10,8 +9,8 @@ import Compiler (successFromJson, runCompiler)
109
1110main :: Effect Unit
1211main = launchAff_ do
13− Tuple input _ <- readSome stdin
14− code <- toStringUTF8 input
12+ { buffers } <- readSome stdin
13+ code <- toStringUTF8 buffers
1514 let settings = { protocol: "https"
1615 , hostname: "compile.purescript.org"
1716 , port: 443
test/Main.purs+1−1
@@ -1,4 +1,4 @@
1−module Test (main) where
1+module Test.Main (main) where
22
33import Prelude (Unit)
44import Effect (Effect)
test/Test/Compiler/ServerMock.purs+28−66
@@ -1,11 +1,7 @@
11module Test.Compiler.ServerMock (settings, setupSrv) where
22
3−import Prelude (Unit, ($), (==), (>>=), (<<<), unit, pure, bind, const, discard)
4−import Control.Apply ((*>))
5−import Control.Monad.Error.Class (throwError, liftMaybe)
6−import Control.Monad.Reader.Trans (ReaderT, ask, runReaderT)
7−import Control.Monad.Trans.Class (lift)
8−import Data.Argonaut.Core (Json, stringify)
3+import Prelude (Unit, ($), (<<<), unit, pure, bind, const)
4+import Data.Argonaut.Core (Json)
95import Data.Argonaut.Decode (JsonDecodeError, printJsonDecodeError)
106import Data.Argonaut.Decode.Class (class DecodeJson, decodeJson)
117import Data.Argonaut.Decode.Generic (genericDecodeJson)
@@ -17,19 +13,13 @@ import Data.Functor ((<$>))
1713import Data.Generic.Rep (class Generic)
1814import Data.Maybe (Maybe(Nothing))
1915import Data.Newtype (class Newtype, unwrap, wrap)
20−import Effect
16+import Node.HTTP.Types (ServerResponse)
17+import Effect (Effect)
2118import Effect.Aff (Aff, bracket)
2219import Effect.Class (liftEffect)
2320import Effect.Exception (Error, error)
24−import HTTPure.Request (Request)
25−import HTTPure.Response (ResponseM, Response, ok)
26−import HTTPure.Server (serve)
27−import HTTPure.Lookup ((!!))
28−import HTTPure.Method (Method(Post))
29−import HTTPure.Body (class Body)
30−import HTTPure.Headers (header)
31−import Node.Stream.Aff (write, end, fromStringUTF8)
32−import Node.HTTP (responseAsStream)
21+import HTTPurple (RouteDuplex', Method(Post), (/), ResponseHeaders, noArgs, mkRoute, serve, ok, notFound, toJson)
22+import HTTPurple.Json.Argonaut (jsonEncoder)
3323import Compiler (Settings, Code, SuccessResult)
3424
3525
@@ -51,26 +41,6 @@ successToJson = (encodeJson :: SuccessResult_ -> Json) <<< wrap
5141successFromJson_ :: Json -> Either Error SuccessResult
5242successFromJson_ json = unwrap <$> (error <<< printJsonDecodeError) `lmap` (decodeJson json :: Either JsonDecodeError SuccessResult_)
5343
54−newtype Json_ = Json_ Json
55−
56−derive instance Newtype Json_ _
57−
58−instance Body Json_ where
59− defaultHeaders _ = pure $ header "Content-Type" "application/json"
60− write json res = do
61− let stream = responseAsStream res
62− body' <- liftEffect $ fromStringUTF8 $ stringify $ unwrap $ json
63− write stream body'
64− end stream
65−
66−type ServerMock = ReaderT Code (ReaderT Request Aff)
67−
68−askRes :: ServerMock Code
69−askRes = ask
70−
71−askReq :: ServerMock Request
72−askReq = lift ask
73−
7444settings :: Settings
7545settings = { protocol: "http"
7646 , hostname: "localhost"
@@ -78,38 +48,30 @@ settings = { protocol: "http"
7848 , parser: successFromJson_
7949 }
8050
81−validatePath :: ServerMock Unit
82−validatePath = do
83− let invalidPath = error "invalid path"
84− missingPath = error "missing path"
85− req <- askReq
86− p <- liftMaybe missingPath $ req.path !! 0
87− case p == "compile" of
88− true -> pure unit
89− false -> throwError invalidPath
90−
91−validateMethod :: ServerMock Unit
92−validateMethod = askReq >>= case _ of
93− { method: Post } -> pure unit
94− _ -> throwError $ error "invalid method"
95−
96−validate :: ServerMock Unit
97−validate = validatePath *> validateMethod
98−
99−answer :: ServerMock Response
100−answer = do
101− res <- askRes
102− let json :: Json_
103− json = wrap $ successToJson { js: res, warnings: Nothing }
104− ok json
105−
106−runServerMock :: Code -> Request -> ResponseM
107−runServerMock res req = runReaderT (runReaderT (validate *> answer) res) req
51+data Route = Compile
52+
53+derive instance Generic Route _
54+
55+route :: RouteDuplex' Route
56+route = mkRoute
57+ { "Compile": "compile" / noArgs
58+ }
59+
60+
61+mkRouter
62+ :: forall a.
63+ String
64+ -> { method :: Method, route :: Route | a }
65+ -> Aff { headers :: ResponseHeaders, status :: Int , writeBody :: ServerResponse -> Aff Unit }
66+mkRouter js = case _ of
67+ { route: Compile, method: Post } -> ok $ toJson jsonEncoder $ successToJson { js, warnings: Nothing }
68+ _ -> notFound
10869
10970launchServerMock :: Code -> Aff (Effect Unit)
110−launchServerMock res = do
111− close <- liftEffect $ serve settings.port (\req -> runServerMock res req) $ pure unit
112− pure $ close $ pure unit
71+launchServerMock c = liftEffect do
72+ let router = mkRouter c
73+ close <- serve { port: settings.port } { route, router }
74+ pure $ close $ pure unit
11375
11476setupSrv :: forall b. Code -> Aff b -> Aff b
11577setupSrv code act = bracket (launchServerMock code) liftEffect (const act)