Skip to content

Commit 82600d4

Browse files
committed
feat: use uncurried functions, add gitlab-ci
1 parent 120c82b commit 82600d4

17 files changed

+180
-134
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Bug report
3+
about: Report an issue
4+
title: ""
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of the bug.
11+
12+
**To Reproduce**
13+
A minimal code example (preferably a runnable example on [Try PureScript](https://try.purescript.org)!) or steps to reproduce the issue.
14+
15+
**Expected behavior**
16+
A clear and concise description of what you expected to happen.
17+
18+
**Additional context**
19+
Add any other context about the problem here.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Change request
3+
about: Propose an improvement to this library
4+
title: ""
5+
labels: ""
6+
assignees: ""
7+
---
8+
9+
**Is your change request related to a problem? Please describe.**
10+
A clear and concise description of the problem.
11+
12+
Examples:
13+
14+
- It's frustrating to have to [...]
15+
- I was looking for a function to [...]
16+
17+
**Describe the solution you'd like**
18+
A clear and concise description of what a good solution to you looks like, including any solutions you've already considered.
19+
20+
**Additional context**
21+
Add any other context about the change request here.

.github/ISSUE_TEMPLATE/config.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: PureScript Discourse
4+
url: https://discourse.purescript.org/
5+
about: Ask and answer questions on the PureScript discussion forum.
6+
- name: PureScript Discord
7+
url: https://purescript.org/chat
8+
about: Ask and answer questions on the PureScript chat.

.github/PULL_REQUEST_TEMPLATE.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**Description of the change**
2+
Clearly and concisely describe the purpose of the pull request. If this PR relates to an existing issue or change proposal, please link to it. Include any other background context that would help reviewers understand the motivation for this PR.
3+
4+
---
5+
6+
**Checklist:**
7+
8+
- [ ] Added the change to the changelog's "Unreleased" section with a link to this PR and your username
9+
- [ ] Linked any existing issues or proposals that this pull request should close
10+
- [ ] Updated or added relevant documentation in the README and/or documentation directory
11+
- [ ] Added a test for the contribution (if applicable)

.github/workflows/ci.yml

+15-34
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,36 @@ name: CI
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [master, main]
66
pull_request:
7-
branches: [main]
7+
branches: [master, main]
88

99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
1312
steps:
14-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v4
1514

16-
- name: Set up PureScript toolchain
15+
- name: Set up a PureScript toolchain
1716
uses: purescript-contrib/setup-purescript@main
1817
with:
19-
purescript: "0.15.0"
18+
purescript: "latest"
19+
purs-tidy: "latest"
20+
spago: "unstable"
2021

2122
- name: Cache PureScript dependencies
22-
uses: actions/cache@v2
23+
uses: actions/cache@v4
2324
with:
24-
key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }}
25+
key: ${{ runner.os }}-spago-${{ hashFiles('**/spago.lock') }}
2526
path: |
2627
.spago
2728
output
2829
29-
- name: Set up Node toolchain
30-
uses: actions/setup-node@v2
31-
with:
32-
node-version: "14.x"
33-
34-
- name: Cache NPM dependencies
35-
uses: actions/cache@v2
36-
env:
37-
cache-name: cache-node-modules
38-
with:
39-
path: ~/.npm
40-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
41-
restore-keys: |
42-
${{ runner.os }}-build-${{ env.cache-name }}-
43-
${{ runner.os }}-build-
44-
${{ runner.os }}-
45-
46-
- name: Install NPM dependencies
47-
run: npm install
48-
49-
- name: Install spago deps
50-
run: npm run deps
30+
- name: Build source
31+
run: spago build --censor-stats --strict --ensure-ranges --pedantic-packages
5132

52-
- name: Build the project
53-
run: npm run build
33+
- name: Run tests
34+
run: spago test --offline --censor-stats --strict --pedantic-packages
5435

55-
- name: Test the project
56-
run: npm run test
36+
- name: Verify formatting
37+
run: purs-tidy check src test

spago.lock

+16-16
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"foldable-traversable",
6565
"foreign",
6666
"foreign-object",
67-
"function s",
67+
"functions",
6868
"functors",
6969
"gen",
7070
"identity",
@@ -139,7 +139,7 @@
139139
"foreign-object",
140140
"fork",
141141
"free",
142-
"function s",
142+
"functions",
143143
"functors",
144144
"gen",
145145
"identity",
@@ -341,7 +341,7 @@
341341
"freeap": "7.0.0",
342342
"freer-free": "0.0.1",
343343
"freet": "7.0.0",
344-
"function s": "6.0.0",
344+
"functions": "6.0.0",
345345
"functor1": "3.0.0",
346346
"functors": "5.0.0",
347347
"fuzzy": "0.4.0",
@@ -733,7 +733,7 @@
733733
"either",
734734
"exceptions",
735735
"foldable-traversable",
736-
"function s",
736+
"functions",
737737
"maybe",
738738
"newtype",
739739
"parallel",
@@ -781,7 +781,7 @@
781781
"control",
782782
"either",
783783
"foreign-object",
784-
"function s",
784+
"functions",
785785
"gen",
786786
"maybe",
787787
"nonempty",
@@ -804,7 +804,7 @@
804804
"bifunctors",
805805
"control",
806806
"foldable-traversable",
807-
"function s",
807+
"functions",
808808
"maybe",
809809
"nonempty",
810810
"partial",
@@ -826,7 +826,7 @@
826826
"effect",
827827
"either",
828828
"exceptions",
829-
"function s",
829+
"functions",
830830
"maybe"
831831
]
832832
},
@@ -906,7 +906,7 @@
906906
"either",
907907
"enums",
908908
"foldable-traversable",
909-
"function s",
909+
"functions",
910910
"gen",
911911
"integers",
912912
"lists",
@@ -1018,7 +1018,7 @@
10181018
"integrity": "sha256-1ORiqoS3HW+qfwSZAppHPWy4/6AQysxZ2t29jcdUMNA=",
10191019
"dependencies": [
10201020
"either",
1021-
"function s",
1021+
"functions",
10221022
"identity",
10231023
"integers",
10241024
"lists",
@@ -1035,7 +1035,7 @@
10351035
"dependencies": [
10361036
"arrays",
10371037
"foldable-traversable",
1038-
"function s",
1038+
"functions",
10391039
"gen",
10401040
"lists",
10411041
"maybe",
@@ -1076,7 +1076,7 @@
10761076
"unsafe-coerce"
10771077
]
10781078
},
1079-
"function s": {
1079+
"functions": {
10801080
"type": "registry",
10811081
"version": "6.0.0",
10821082
"integrity": "sha256-adMyJNEnhGde2unHHAP79gPtlNjNqzgLB8arEOn9hLI=",
@@ -1253,7 +1253,7 @@
12531253
"dependencies": [
12541254
"effect",
12551255
"either",
1256-
"function s",
1256+
"functions",
12571257
"maybe",
12581258
"nullable",
12591259
"prelude",
@@ -1270,7 +1270,7 @@
12701270
"either",
12711271
"enums",
12721272
"exceptions",
1273-
"function s",
1273+
"functions",
12741274
"integers",
12751275
"js-date",
12761276
"maybe",
@@ -1357,7 +1357,7 @@
13571357
"integrity": "sha256-yiGBVl3AD+Guy4kNWWeN+zl1gCiJK+oeIFtZtPCw4+o=",
13581358
"dependencies": [
13591359
"effect",
1360-
"function s",
1360+
"functions",
13611361
"maybe"
13621362
]
13631363
},
@@ -1366,7 +1366,7 @@
13661366
"version": "9.0.1",
13671367
"integrity": "sha256-/9M6aeMDBdB4cwYDeJvLFprAHZ49EbtKQLIJsneXLIk=",
13681368
"dependencies": [
1369-
"function s",
1369+
"functions",
13701370
"maybe"
13711371
]
13721372
},
@@ -1533,7 +1533,7 @@
15331533
"version": "4.0.0",
15341534
"integrity": "sha256-Za5U85bTRJEfGK5Sk4hM41oXy84YQI0I8TL3WUn1Qzg=",
15351535
"dependencies": [
1536-
"function s",
1536+
"functions",
15371537
"prelude",
15381538
"unsafe-coerce"
15391539
]

spago.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ package:
3131
workspace:
3232
extraPackages: {}
3333
packageSet:
34-
registry: 63.6.0
34+
registry: 63.6.0

src/React/Basic/DOM.js

+10-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
1-
import * as ReactDOM from 'react-dom';
2-
3-
export function renderThen(jsx) {
4-
return (node) => (callback) => () =>
5-
ReactDOM.render(jsx, node, callback);
6-
}
7-
8-
export function hydrateThen(jsx) {
9-
return (node) => (callback) => () =>
10-
ReactDOM.hydrate(jsx, node, callback);
11-
}
12-
13-
export function unmount(node) {
14-
return () => ReactDOM.unmountComponentAtNode(node);
15-
}
16-
17-
export function createPortal(jsx) {
18-
return (node) => ReactDOM.createPortal(jsx, node);
19-
}
20-
21-
export function flushSync(callback) {
22-
return () => ReactDOM.flushSync(callback);
23-
}
1+
import ReactDOM from "react-dom";
2+
3+
// eslint-disable-next-line react/no-deprecated
4+
export const renderThenFn = ReactDOM.render;
5+
// eslint-disable-next-line react/no-deprecated
6+
export const hydrateThenFn = ReactDOM.hydrate;
7+
// eslint-disable-next-line react/no-deprecated
8+
export const unmountComponentAtNode = ReactDOM.unmountComponentAtNode;
9+
export const createPortalFn = ReactDOM.createPortal;
10+
export const flushSyncFn = ReactDOM.flushSync;

src/React/Basic/DOM.purs

+18-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ module React.Basic.DOM
1919

2020
import Prelude
2121

22+
import Data.Function.Uncurried (Fn2, runFn2)
2223
import Effect (Effect)
24+
import Effect.Uncurried (EffectFn1, runEffectFn1, EffectFn3, runEffectFn3)
2325
import Prim.TypeError (class Warn, Text)
2426
import React.Basic (JSX)
2527
import React.Basic.DOM.Generated (Props_a, Props_abbr, Props_address, Props_area, Props_article, Props_aside, Props_audio, Props_b, Props_base, Props_bdi, Props_bdo, Props_blockquote, Props_body, Props_br, Props_button, Props_canvas, Props_caption, Props_cite, Props_code, Props_col, Props_colgroup, Props_data, Props_datalist, Props_dd, Props_del, Props_details, Props_dfn, Props_dialog, Props_div, Props_dl, Props_dt, Props_em, Props_embed, Props_fieldset, Props_figcaption, Props_figure, Props_footer, Props_form, Props_h1, Props_h2, Props_h3, Props_h4, Props_h5, Props_h6, Props_head, Props_header, Props_hgroup, Props_hr, Props_html, Props_i, Props_iframe, Props_img, Props_input, Props_ins, Props_kbd, Props_keygen, Props_label, Props_legend, Props_li, Props_link, Props_main, Props_map, Props_mark, Props_math, Props_menu, Props_menuitem, Props_meta, Props_meter, Props_nav, Props_noscript, Props_object, Props_ol, Props_optgroup, Props_option, Props_output, Props_p, Props_param, Props_picture, Props_pre, Props_progress, Props_q, Props_rb, Props_rp, Props_rt, Props_rtc, Props_ruby, Props_s, Props_samp, Props_script, Props_section, Props_select, Props_slot, Props_small, Props_source, Props_span, Props_strong, Props_style, Props_sub, Props_summary, Props_sup, Props_table, Props_tbody, Props_td, Props_template, Props_textarea, Props_tfoot, Props_th, Props_thead, Props_time, Props_title, Props_tr, Props_track, Props_u, Props_ul, Props_var, Props_video, Props_wbr, a, a', a_, abbr, abbr', abbr_, address, address', address_, area, area', article, article', article_, aside, aside', aside_, audio, audio', audio_, b, b', b_, base, base', bdi, bdi', bdi_, bdo, bdo', bdo_, blockquote, blockquote', blockquote_, body, body', body_, br, br', button, button', button_, canvas, canvas', canvas_, caption, caption', caption_, cite, cite', cite_, code, code', code_, col, col', colgroup, colgroup', colgroup_, data', data'', data_, datalist, datalist', datalist_, dd, dd', dd_, del, del', del_, details, details', details_, dfn, dfn', dfn_, dialog, dialog', dialog_, div, div', div_, dl, dl', dl_, dt, dt', dt_, em, em', em_, embed, embed', fieldset, fieldset', fieldset_, figcaption, figcaption', figcaption_, figure, figure', figure_, footer, footer', footer_, form, form', form_, h1, h1', h1_, h2, h2', h2_, h3, h3', h3_, h4, h4', h4_, h5, h5', h5_, h6, h6', h6_, head, head', head_, header, header', header_, hgroup, hgroup', hgroup_, hr, hr', html, html', html_, i, i', i_, iframe, iframe', iframe_, img, img', input, input', ins, ins', ins_, kbd, kbd', kbd_, keygen, keygen', keygen_, label, label', label_, legend, legend', legend_, li, li', li_, link, link', main, main', main_, map, map', map_, mark, mark', mark_, math, math', math_, menu, menu', menu_, menuitem, menuitem', menuitem_, meta, meta', meter, meter', meter_, nav, nav', nav_, noscript, noscript', noscript_, object, object', object_, ol, ol', ol_, optgroup, optgroup', optgroup_, option, option', option_, output, output', output_, p, p', p_, param, param', picture, picture', picture_, pre, pre', pre_, progress, progress', progress_, q, q', q_, rb, rb', rb_, rp, rp', rp_, rt, rt', rt_, rtc, rtc', rtc_, ruby, ruby', ruby_, s, s', s_, samp, samp', samp_, script, script', script_, section, section', section_, select, select', select_, slot, slot', slot_, small, small', small_, source, source', span, span', span_, strong, strong', strong_, style, style', style_, sub, sub', sub_, summary, summary', summary_, sup, sup', sup_, table, table', table_, tbody, tbody', tbody_, td, td', td_, template, template', template_, textarea, textarea', textarea_, tfoot, tfoot', tfoot_, th, th', th_, thead, thead', thead_, time, time', time_, title, title', title_, tr, tr', tr_, track, track', u, u', u_, ul, ul', ul_, var, var', var_, video, video', video_, wbr, wbr') as Generated
@@ -50,9 +52,9 @@ render'
5052
-> Element
5153
-> Effect Unit
5254
-> Effect Unit
53-
render' = renderThen
55+
render' = runEffectFn3 renderThenFn
5456

55-
foreign import renderThen :: JSX -> Element -> Effect Unit -> Effect Unit
57+
foreign import renderThenFn :: EffectFn3 JSX Element (Effect Unit) Unit
5658

5759
-- | Render or update/re-render a component tree into
5860
-- | a DOM element, attempting to reuse the existing
@@ -82,22 +84,28 @@ hydrate'
8284
-> Element
8385
-> Effect Unit
8486
-> Effect Unit
85-
hydrate' = hydrateThen
87+
hydrate' = runEffectFn3 hydrateThenFn
8688

87-
foreign import hydrateThen :: JSX -> Element -> Effect Unit -> Effect Unit
89+
foreign import hydrateThenFn :: EffectFn3 JSX Element (Effect Unit) Unit
8890

8991
-- | Attempt to unmount and clean up the React app
9092
-- | rendered into the given element. Returns `true`
9193
-- | if an app existed and was unmounted successfully.
9294
-- |
9395
-- | __*Note:* Relies on `ReactDOM.unmountComponentAtNode`__
9496
-- | __*Note:* `unmount` has been replaced with `Client.unmountRoot` in React 18
95-
foreign import unmount :: Element -> Effect Boolean
97+
unmount :: Element -> Effect Boolean
98+
unmount = runEffectFn1 unmountComponentAtNode
99+
100+
foreign import unmountComponentAtNode :: EffectFn1 Element Boolean
96101

97102
-- | Divert a render tree into a separate DOM node. The node's
98103
-- | content will be overwritten and managed by React, similar
99104
-- | to `render` and `hydrate`.
100-
foreign import createPortal :: JSX -> Element -> JSX
105+
createPortal :: JSX -> Element -> JSX
106+
createPortal = runFn2 createPortalFn
107+
108+
foreign import createPortalFn :: Fn2 JSX Element JSX
101109

102110
-- | Create a text node.
103111
text :: String -> JSX
@@ -112,4 +120,7 @@ text = unsafeCoerce
112120
-- | flushSync (setMessages (_ <> [msg]))
113121
-- | scrollToLastMessage
114122
-- | ```
115-
foreign import flushSync :: forall a. Effect a -> Effect a
123+
flushSync :: forall a. Effect a -> Effect a
124+
flushSync = runEffectFn1 flushSyncFn
125+
126+
foreign import flushSyncFn :: forall a. EffectFn1 (Effect a) a

0 commit comments

Comments
 (0)