Skip to content

Commit 115dc3c

Browse files
authored
Updates for PS 0.14 (#11)
* Updates for PS 0.14 * Update workflow versions * Add missing period
1 parent 0b2bd4b commit 115dc3c

File tree

10 files changed

+171
-174
lines changed

10 files changed

+171
-174
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212

1313
- uses: thomashoneyman/setup-purescript@main
1414
with:
15-
purescript: "0.13.8"
16-
spago: "0.18.1"
15+
purescript: "0.14.0"
16+
spago: "0.19.1"
1717

1818
- name: Cache PureScript dependencies
1919
uses: actions/cache@v2

bower.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"output"
1515
],
1616
"dependencies": {
17-
"purescript-aff": "^v5.1.2",
18-
"purescript-event": "^v1.3.0",
19-
"purescript-free": "^v5.2.0",
20-
"purescript-freeap": "^v5.0.1",
21-
"purescript-react-basic-hooks": "^v6.2.0",
22-
"purescript-refs": "^v4.1.0",
23-
"purescript-unsafe-reference": "^v3.1.0"
17+
"purescript-aff": "^v6.0.0",
18+
"purescript-free": "^v6.0.0",
19+
"purescript-freeap": "^v6.0.0",
20+
"purescript-halogen-subscriptions": "^v1.0.0",
21+
"purescript-react-basic-hooks": "^v7.0.0",
22+
"purescript-refs": "^v5.0.0",
23+
"purescript-unsafe-reference": "^v4.0.0"
2424
}
2525
}

package-lock.json

Lines changed: 141 additions & 143 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"author": "",
1212
"license": "ISC",
1313
"devDependencies": {
14-
"bower": "^1.8.8",
14+
"bower": "^1.8.12",
1515
"pulp": "^15.0.0",
16-
"purescript": "^0.13.8",
17-
"purescript-psa": "^0.8.0",
18-
"purty": "^6.3.0",
16+
"purescript": "^0.14.0",
17+
"purescript-psa": "^0.8.2",
18+
"purty": "^7.0.0",
1919
"rimraf": "^3.0.2",
20-
"spago": "^0.18.1"
20+
"spago": "^0.19.1"
2121
}
2222
}

packages.dhall

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,8 @@ let additions =
116116
}
117117
-------------------------------
118118
-}
119-
120-
121119
let upstream =
122-
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20201223/packages.dhall sha256:a1a8b096175f841c4fef64c9b605fb0d691229241fd2233f6cf46e213de8a185
120+
https://raw.githubusercontent.com/purescript/package-sets/master/src/packages.dhall sha256:5bfea0ec14831c81482d72ffdcaf476e317d69d0788f49a08f05b619a4f70b47
123121

124122
let overrides = {=}
125123

spago.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You can edit this file as you like.
66
, license = "BSD-3-Clause"
77
, repository = "https://github.com/robertdp/purescript-react-halo.git"
88
, dependencies =
9-
[ "aff", "event", "free", "freeap", "react-basic-hooks", "refs", "unsafe-reference" ]
9+
[ "aff", "free", "freeap", "halogen-subscriptions", "react-basic-hooks", "refs", "unsafe-reference" ]
1010
, packages = ./packages.dhall
1111
, sources = [ "src/**/*.purs" ]
1212
}

src/React/Halo/Internal/Control.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Data.Bifunctor (lmap)
1414
import Data.Tuple (Tuple)
1515
import Effect.Aff.Class (class MonadAff, liftAff)
1616
import Effect.Class (class MonadEffect, liftEffect)
17-
import FRP.Event (Event)
17+
import Halogen.Subscription (Emitter)
1818
import React.Halo.Internal.Types (ForkId, SubscriptionId)
1919

2020
-- | The Halo evaluation algebra
@@ -29,7 +29,7 @@ data HaloF props ctx state action (m :: Type -> Type) a
2929
= Props (props -> a)
3030
| Context (ctx -> a)
3131
| State (state -> Tuple a state)
32-
| Subscribe (SubscriptionId -> Event action) (SubscriptionId -> a)
32+
| Subscribe (SubscriptionId -> Emitter action) (SubscriptionId -> a)
3333
| Unsubscribe SubscriptionId a
3434
| Lift (m a)
3535
| Par (HaloAp props ctx state action m a)
@@ -150,16 +150,16 @@ props = HaloM (liftF (Props identity))
150150
context :: forall props ctx state action m. HaloM props ctx state action m ctx
151151
context = HaloM (liftF (Context identity))
152152

153-
-- | Subscribe to new actions from an `Event`. Subscriptions will be automatically cancelled when the component
153+
-- | Subscribe to new actions from an `Emitter`. Subscriptions will be automatically cancelled when the component
154154
-- | unmounts.
155155
-- |
156156
-- | Returns a `SubscriptionId` which can be used with `unsubscribe` to manually cancel a subscription.
157-
subscribe :: forall props ctx state action m. Event action -> HaloM props ctx state action m SubscriptionId
157+
subscribe :: forall props ctx state action m. Emitter action -> HaloM props ctx state action m SubscriptionId
158158
subscribe = subscribe' <<< const
159159

160160
-- | Same as `subscribe` but the event-producing logic is also passed the `SuscriptionId`. This is useful when events
161161
-- | need to unsubscribe themselves.
162-
subscribe' :: forall props ctx state action m. (SubscriptionId -> Event action) -> HaloM props ctx state action m SubscriptionId
162+
subscribe' :: forall props ctx state action m. (SubscriptionId -> Emitter action) -> HaloM props ctx state action m SubscriptionId
163163
subscribe' event = HaloM (liftF (Subscribe event identity))
164164

165165
-- | Cancels the event subscription belonging to the `SubscriptionId`.

src/React/Halo/Internal/Eval.purs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Prelude
44
import Control.Applicative.Free (foldFreeAp)
55
import Control.Monad.Free (foldFree)
66
import Data.Either (either)
7-
import Data.Foldable (sequence_, traverse_)
7+
import Data.Foldable (traverse_)
88
import Data.Map as Map
99
import Data.Maybe (Maybe(..))
1010
import Data.Tuple (Tuple(..))
@@ -13,7 +13,7 @@ import Effect.Aff (Aff, ParAff, finally, parallel, sequential, throwError)
1313
import Effect.Aff as Aff
1414
import Effect.Class (liftEffect)
1515
import Effect.Ref as Ref
16-
import FRP.Event as Event
16+
import Halogen.Subscription (subscribe, unsubscribe)
1717
import React.Halo.Internal.Control (HaloAp(..), HaloF(..), HaloM(..))
1818
import React.Halo.Internal.State (HaloState(..))
1919
import React.Halo.Internal.State as State
@@ -53,13 +53,13 @@ evalHaloF hs@(HaloState s) = case _ of
5353
liftEffect do
5454
sid <- State.fresh SubscriptionId hs
5555
unlessM (Ref.read s.finalized) do
56-
canceller <- Event.subscribe (sub sid) (handleAction hs)
56+
canceller <- subscribe (sub sid) (handleAction hs)
5757
Ref.modify_ (Map.insert sid canceller) s.subscriptions
5858
pure (k sid)
5959
Unsubscribe sid a ->
6060
liftEffect do
61-
canceller <- Map.lookup sid <$> Ref.read s.subscriptions
62-
sequence_ canceller
61+
subscription <- Map.lookup sid <$> Ref.read s.subscriptions
62+
traverse_ unsubscribe subscription
6363
pure a
6464
Lift m -> m
6565
Par p -> sequential (evalHaloAp hs p)
@@ -143,7 +143,7 @@ runFinalize :: forall props ctx state action. HaloState props ctx state action -
143143
runFinalize hs@(HaloState s) = do
144144
Ref.write true s.finalized
145145
subscriptions <- Ref.modify' (\s' -> { state: Map.empty, value: s' }) s.subscriptions
146-
sequence_ (Map.values subscriptions)
146+
traverse_ unsubscribe (Map.values subscriptions)
147147
forks <- Ref.modify' (\s' -> { state: Map.empty, value: s' }) s.forks
148148
traverse_ (runAff <<< Aff.killFiber (Aff.error "Cancelled")) (Map.values forks)
149149
runAff $ evalHaloM hs $ s.eval Finalize

src/React/Halo/Internal/State.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Effect (Effect)
77
import Effect.Aff (Aff, Fiber)
88
import Effect.Ref (Ref)
99
import Effect.Ref as Ref
10+
import Halogen.Subscription (Subscription)
1011
import React.Halo.Internal.Control (HaloM)
1112
import React.Halo.Internal.Types (ForkId, Lifecycle, SubscriptionId)
1213

@@ -20,7 +21,7 @@ newtype HaloState props ctx state action
2021
, context :: Ref ctx
2122
, state :: Ref state
2223
, fresh :: Ref Int
23-
, subscriptions :: Ref (Map SubscriptionId (Effect Unit))
24+
, subscriptions :: Ref (Map SubscriptionId Subscription)
2425
, forks :: Ref (Map ForkId (Fiber Unit))
2526
}
2627

src/React/Halo/Internal/Types.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Prelude
77
-- | - `Initialize` contains the initial props. It occurs when the component mounts, and only once per component.
88
-- | - `Update` contains the previous and new props. It occurs when the component re-renders and the props have changes.
99
-- | - `Action` contains the dispatched action. It occurs each time an action is dispatched to be eval'd, up until the
10-
-- | `Finalize` event
10+
-- | `Finalize` event.
1111
-- | - `Finalize` occurs when the component unmounts.
1212
data Lifecycle props ctx action
1313
= Initialize { props :: props, context :: ctx }

0 commit comments

Comments
 (0)