Skip to content

Commit 3f80d11

Browse files
authored
Clean up (#93)
* Keep only tea like updating * Update actions * Update actions * Update benchmarks * Update docs * Update mode docs
1 parent 90265f9 commit 3f80d11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+276
-1190
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v2
11-
- uses: actions/setup-node@v2
11+
- uses: actions/setup-node@v4
1212
with:
13-
node-version: '15'
13+
node-version: '22'
1414
cache: 'npm'
1515

1616
- uses: purescript-contrib/setup-purescript@main
1717

1818
- name: Cache PureScript dependencies
19-
uses: actions/cache@v2
19+
uses: actions/cache@v4
2020
# This cache uses the .dhall files to know when it should reinstall
2121
# and rebuild packages. It caches both the installed packages from
2222
# the `.spago` directory and compilation artifacts from the `output`

benchmarks/js-framework-benchmark/keyed/src/Main.purs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import Prelude
55
import Data.Array ((!!))
66
import Data.Array as DA
77
import Data.Maybe (Maybe(..))
8+
import Data.Tuple.Nested ((/\))
89
import Effect (Effect)
910
import Effect.Aff (Aff)
1011
import Effect.Class (liftEffect)
1112
import Effect.Uncurried (EffectFn2)
1213
import Effect.Uncurried as EU
13-
import Flame (Html, ListUpdate, QuerySelector(..), (:>))
14+
import Flame (Html, Update)
1415
import Flame as F
1516
import Flame.Html.Attribute as HA
1617
import Flame.Html.Element as HE
17-
18-
import Flame.Types(NodeData)
18+
import Flame.Types (NodeData)
19+
import Web.DOM.ParentNode (QuerySelector(..))
1920

2021
data Message =
2122
Create Int |
@@ -52,7 +53,7 @@ createRandomNRows n lastID = liftEffect (EU.runEffectFn2 createRandomNRows_ n la
5253

5354
main :: Effect Unit
5455
main = F.mount_ (QuerySelector "body") {
55-
init: model :> [],
56+
model: model,
5657
subscribe: [],
5758
view,
5859
update
@@ -133,15 +134,15 @@ spacer = HE.td' [ HA.class' "col-md-6" ]
133134
footer :: Html Message
134135
footer = HE.span' [ HA.class' "preloadicon glyphicon glyphicon-remove", HA.createAttribute "aria-hidden" "true" ]
135136

136-
update :: ListUpdate Model Message
137+
update :: Update Model Message
137138
update model =
138139
case _ of
139-
Create amount -> model :> [map (\rows -> Just (DisplayCreated rows)) (createRandomNRows amount model.lastID)]
140+
Create amount -> model /\ [map (\rows -> Just (DisplayCreated rows)) (createRandomNRows amount model.lastID)]
140141
DisplayCreated rows -> F.noMessages (model { lastID = model.lastID + DA.length rows, rows = rows })
141142

142143
AppendOneThousand ->
143144
let amount = 1000
144-
in model :> [map (\rows -> Just (DisplayAppended rows)) (createRandomNRows amount model.lastID)]
145+
in model /\ [map (\rows -> Just (DisplayAppended rows)) (createRandomNRows amount model.lastID)]
145146
DisplayAppended newRows -> F.noMessages (model { lastID = model.lastID + DA.length newRows, rows = model.rows <> newRows })
146147

147148
UpdateEveryTenth -> F.noMessages model { rows = DA.mapWithIndex updateLabel model.rows }

benchmarks/js-framework-benchmark/non-keyed/src/Main.purs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module Main where
22

3-
import Prelude (Unit, bind, map, mod, pure, show, (+), (/=), (<>), (==), otherwise)
4-
53
import Data.Array ((!!))
64
import Data.Array as DA
75
import Data.Maybe (Maybe(..))
@@ -10,12 +8,13 @@ import Effect.Aff (Aff)
108
import Effect.Class (liftEffect)
119
import Effect.Uncurried (EffectFn2)
1210
import Effect.Uncurried as EU
13-
import Flame.Application.EffectList (ListUpdate)
14-
import Flame.Types((:>), Html, NodeData)
15-
import Web.DOM.ParentNode(QuerySelector(..))
11+
import Flame as F
1612
import Flame.Application.EffectList as F
1713
import Flame.Html.Attribute as HA
1814
import Flame.Html.Element as HE
15+
import Flame.Types ((/\), Html, NodeData)
16+
import Prelude (Unit, bind, map, mod, pure, show, (+), (/=), (<>), (==), otherwise)
17+
import Web.DOM.ParentNode (QuerySelector(..))
1918

2019
data Message =
2120
Create Int |
@@ -52,7 +51,7 @@ createRandomNRows n lastID = liftEffect (EU.runEffectFn2 createRandomNRows_ n la
5251

5352
main :: Effect Unit
5453
main = F.mount_ (QuerySelector "main") {
55-
init: model :> [],
54+
model: model,
5655
view,
5756
subscribe: [],
5857
update
@@ -133,15 +132,15 @@ spacer = HE.td' [ HA.class' "col-md-6" ]
133132
footer :: Html Message
134133
footer = HE.span' [ HA.class' "preloadicon glyphicon glyphicon-remove", HA.createAttribute "aria-hidden" "true" ]
135134

136-
update :: ListUpdate Model Message
135+
update :: Update Model Message
137136
update model =
138137
case _ of
139-
Create amount -> model :> [map (\rows -> Just (DisplayCreated rows)) (createRandomNRows amount model.lastID)]
138+
Create amount -> model /\ [map (\rows -> Just (DisplayCreated rows)) (createRandomNRows amount model.lastID)]
140139
DisplayCreated rows -> F.noMessages (model { lastID = model.lastID + DA.length rows, rows = rows })
141140

142141
AppendOneThousand ->
143142
let amount = 1000
144-
in model :> [map (\rows -> Just (DisplayAppended rows)) (createRandomNRows amount model.lastID)]
143+
in model /\ [map (\rows -> Just (DisplayAppended rows)) (createRandomNRows amount model.lastID)]
145144
DisplayAppended newRows -> F.noMessages (model { lastID = model.lastID + DA.length newRows, rows = model.rows <> newRows})
146145

147146
UpdateEveryTenth -> F.noMessages model { rows = DA.mapWithIndex updateLabel model.rows }

docs/concepts.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ A Flame application consists of the following record
1010

1111
```haskell
1212
type Application model message = {
13-
init :: model,
13+
model :: model,
1414
view :: model -> Html message,
15-
update :: model -> message -> model,
15+
update :: Update model message,
1616
subscribe :: Array (Subscription message)
1717
}
1818
```
@@ -31,11 +31,11 @@ that is, the state of our application is a single integer. In a real world appli
3131
With our model type declared, we can define the initial state of the application
3232

3333
```haskell
34-
init :: Model
35-
init = 0
34+
model :: Model
35+
model = 0
3636
```
3737

38-
The first time the application is rendered, Flame calls the view function with `init`.
38+
The first time the application is rendered, Flame calls the view function with `model`.
3939

4040
### Application markup
4141

@@ -67,13 +67,13 @@ data Message = Increment | Decrement
6767
and thus our update function looks like
6868

6969
```haskell
70-
update :: Model -> Message -> Model
70+
update :: Update Model Message
7171
update model = case _ of
72-
Increment -> model + 1
73-
Decrement -> model - 1
72+
Increment -> model + 1 /\ []
73+
Decrement -> model - 1 /\ []
7474
```
7575

76-
See [Handling events](events) for an in depth look at update strategies.
76+
See [Handling events](events) for an in depth look at updates.
7777

7878
### Subscriptions
7979

@@ -84,19 +84,18 @@ In the counter example no external events are handled, so the subscription list
8484
```haskell
8585
subscribe :: Array (Subscription Message)
8686
subscribe = []
87-
}
8887
```
8988

90-
See [Handling external events](events#handling-external-events) for an in depth look at subscriptions.
89+
See [Subscriptions](events#subscriptions) for an in depth look at subscriptions.
9190

9291
### Rendering
9392

9493
Having all pieces put together, we can either render the application to the DOM, as in the case of the counter example
9594

9695
```haskell
9796
main :: Effect Unit
98-
main = FAN.mount_ (QuerySelector "body") {
99-
init,
97+
main = F.mount_ (QuerySelector "body") {
98+
model,
10099
view,
101100
update,
102101
subscribe

0 commit comments

Comments
 (0)