Skip to content

Commit c409968

Browse files
authored
Merge pull request #24 from ptrfrncsmrph/purs-0_15-updates
PureScript 0.15 updates
2 parents d725f19 + 8bff7b1 commit c409968

19 files changed

+6947
-347
lines changed

.github/workflows/ci.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [12.x, 14.x, 16.x, 18.x]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Set up PureScript toolchain
21+
uses: purescript-contrib/setup-purescript@main
22+
with:
23+
purescript: "0.15.0"
24+
25+
- name: Set up Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v2
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
- name: Cache NPM dependencies
31+
uses: actions/cache@v2
32+
env:
33+
cache-name: cache-node-modules
34+
with:
35+
path: ~/.npm
36+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
37+
restore-keys: |
38+
${{ runner.os }}-build-${{ env.cache-name }}-
39+
${{ runner.os }}-build-
40+
${{ runner.os }}-
41+
42+
- name: Install NPM dependencies
43+
run: npm install
44+
45+
- name: Install spago deps
46+
run: npm run deps
47+
48+
- name: Build the project
49+
run: npm run build
50+
51+
- name: Build examples
52+
run: npm run example

.github/workflows/nodejs.yml

-26
This file was deleted.

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
/.purs*
99
/.psa*
1010
/.vscode/
11+
/.spago/
12+
/output-pulp/
13+
.psc-*

.travis.yml

-11
This file was deleted.

bower.json

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
{
22
"name": "purescript-react-dnd-basic",
3+
"license": [
4+
"Apache-2.0"
5+
],
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/lumihq/purescript-react-dnd-basic"
9+
},
310
"ignore": [
411
"**/.*",
512
"node_modules",
613
"bower_components",
714
"output"
815
],
9-
"license": "Apache-2.0",
10-
"repository": {
11-
"type": "git",
12-
"url": "https://github.com/lumihq/purescript-react-dnd-basic.git"
13-
},
1416
"dependencies": {
15-
"purescript-prelude": "^4.1.1",
16-
"purescript-nullable": "^4.1.1",
17-
"purescript-promises": "^3.1.1",
18-
"purescript-react-basic-dom": "lumihq/purescript-react-basic-dom#^3.3.0",
19-
"purescript-react-basic-hooks": "^6.0.0"
17+
"purescript-console": "^v6.0.0",
18+
"purescript-effect": "^v4.0.0",
19+
"purescript-maybe": "^v6.0.0",
20+
"purescript-nullable": "^v6.0.0",
21+
"purescript-prelude": "^v6.0.0",
22+
"purescript-react-basic-hooks": "^v8.0.0",
23+
"purescript-web-dom": "^v6.0.0"
2024
},
21-
"devDependencies": {
22-
"purescript-psci-support": "^4.0.0"
25+
"resolutions": {
26+
"purescript-prelude": "^6.0.0",
27+
"purescript-newtype": "^5.0.0",
28+
"purescript-control": "^6.0.0",
29+
"purescript-unsafe-coerce": "^6.0.0",
30+
"purescript-safe-coerce": "^2.0.0"
2331
}
2432
}

examples/basic/Makefile

-8
This file was deleted.

examples/basic/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
## Building
44

5+
You can build this example from the root of the `purescript-react-dnd-basic` project:
6+
57
```sh
68
npm install
7-
make all
9+
npm run example:basic
810
```
911

10-
This will compile the PureScript source files, bundle them, and use Browserify to combine PureScript and NPM sources into a single bundle.
12+
This will compile the PureScript source files, bundle them, and combine PureScript and NPM sources into a single bundle.
1113

1214
Then open `html/index.html` in your browser.

examples/basic/index.js

-9
This file was deleted.

examples/basic/package.json

-17
This file was deleted.

examples/basic/spago.dhall

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
let config = ./../../spago.dhall
2+
3+
in config
4+
// { sources = config.sources # [ "examples/basic/**/*.purs" ]
5+
, dependencies =
6+
config.dependencies
7+
# [ "arrays"
8+
, "exceptions"
9+
, "foldable-traversable"
10+
, "integers"
11+
, "react-basic"
12+
, "react-basic-dom"
13+
, "web-html"
14+
]
15+
}

examples/basic/src/Basic.purs

+31-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
module Basic where
1+
module Example.Basic where
22

33
import Prelude
44
import Data.Array ((!!), drop, mapWithIndex, take)
55
import Data.Foldable (traverse_)
66
import Data.Int as Int
7-
import Data.Maybe (fromMaybe, maybe)
7+
import Data.Maybe (fromMaybe, maybe, Maybe(..))
88
import Effect (Effect)
9+
import Effect.Class.Console as Console
10+
import Effect.Exception (throw)
11+
import React.Basic.DOM (render)
912
import React.Basic.DOM as R
1013
import React.Basic.DOM.Events (targetChecked)
1114
import React.Basic.Events as Events
1215
import React.Basic.Hooks (Component, component, fragment, mkReducer, useReducer, (/\))
1316
import React.Basic.Hooks as React
1417
import React.Basic.ReactDND (dndProvider, mergeTargets, useDrag, useDrop)
1518
import React.Basic.ReactDND.Backends.HTML5Backend (html5Backend)
19+
import Web.DOM.NonElementParentNode (getElementById)
20+
import Web.HTML (window)
21+
import Web.HTML.HTMLDocument (toNonElementParentNode)
22+
import Web.HTML.Window (document)
1623

1724
data Action
1825
= Move { from :: Int, to :: Int }
1926
| SetDone String Boolean
2027

21-
type Todo
22-
= { id :: String, text :: String, done :: Boolean }
28+
type Todo = { id :: String, text :: String, done :: Boolean }
2329

2430
mkTodoExample :: Component Unit
2531
mkTodoExample = do
@@ -34,7 +40,7 @@ mkTodoExample = do
3440
, R.p_ [ R.text "Drag to reorder the list:" ]
3541
, R.section_
3642
$ state.todos
37-
# mapWithIndex \index t -> todo { index, todo: t, dispatch }
43+
# mapWithIndex \index t -> todo { index, todo: t, dispatch }
3844
]
3945
where
4046
initialState =
@@ -53,20 +59,20 @@ mkTodoExample = do
5359
SetDone id done ->
5460
state
5561
{ todos =
56-
state.todos
57-
<#> \t ->
62+
state.todos
63+
<#> \t ->
5864
if t.id == id then
5965
t { done = done }
6066
else
6167
t
6268
}
6369

64-
mkTodo ::
65-
Component
66-
{ index :: Int
67-
, todo :: Todo
68-
, dispatch :: Action -> Effect Unit
69-
}
70+
mkTodo
71+
:: Component
72+
{ index :: Int
73+
, todo :: Todo
74+
, dispatch :: Action -> Effect Unit
75+
}
7076
mkTodo = do
7177
let
7278
todoDND = "todo-dnd"
@@ -119,3 +125,15 @@ moveItem fromIndex toIndex items =
119125
take toIndex items'
120126
<> maybe [] pure item
121127
<> drop toIndex items'
128+
129+
main :: Effect Unit
130+
main = do
131+
maybeContainer <- window
132+
>>= document
133+
>>= toNonElementParentNode
134+
>>> getElementById "container"
135+
case maybeContainer of
136+
Nothing -> throw "Container element not found."
137+
Just container -> do
138+
todoExample <- mkTodoExample
139+
render (todoExample unit) container

0 commit comments

Comments
 (0)