Skip to content

Commit 057b92c

Browse files
authored
Update to Purescript v0.15.4 (#32)
1 parent 7a0ed54 commit 057b92c

37 files changed

+126
-158
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "purescript-react-realworld",
3-
"version": "3.0.0",
3+
"version": "4.0.0",
44
"description": "A real-world application demonstrating PureScript and React",
55
"keywords": [
66
"Purescript",
@@ -32,16 +32,16 @@
3232
},
3333
"devDependencies": {
3434
"parcel": "2.0.0",
35-
"purescript": "^0.14.5",
35+
"purescript": "^0.15.4",
3636
"purescript-psa": "^0.8.2",
37-
"spago": "^0.20.3",
37+
"purs-tidy": "^0.9.2",
38+
"spago": "^0.20.9",
3839
"zephyr": "https://github.com/jonasbuntinx/zephyr.git"
3940
},
4041
"dependencies": {
41-
"dayjs": "^1.10.7",
42+
"dayjs": "^1.11.5",
4243
"nano-markdown": "^1.2.1",
43-
"preact": "^10.5.15",
44-
"xhr2": "^0.2.1"
44+
"preact": "^10.11.0"
4545
},
4646
"alias": {
4747
"react": "preact/compat",

packages.dhall

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,10 @@ let additions =
117117
-------------------------------
118118
-}
119119
let upstream =
120-
https://github.com/purescript/package-sets/releases/download/psc-0.14.2-20210713/packages.dhall sha256:654c3148cb995f642c73b4508d987d9896e2ad3ea1d325a1e826c034c0d3cd7b
120+
https://github.com/purescript/package-sets/releases/download/psc-0.15.4-20220901/packages.dhall
121+
sha256:f1531b29c21ac437ffe5666c1b6cc76f0a9c29d3c9d107ff047aa2567744994f
121122

122123
let additions =
123-
{ web-router =
124-
{ dependencies =
125-
[ "aff"
126-
, "effect"
127-
, "freet"
128-
, "indexed-monad"
129-
, "prelude"
130-
, "profunctor-lenses"
131-
, "routing"
132-
]
133-
, repo = "https://github.com/robertdp/purescript-web-router.git"
134-
, version = "v0.3.0"
135-
}
136-
}
124+
{=}
137125

138126
in upstream // additions

spago.dhall

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
, dependencies =
33
[ "aff"
44
, "affjax"
5+
, "affjax-web"
56
, "argonaut-core"
67
, "arrays"
78
, "bifunctors"

src/Conduit/Api/Client.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Conduit.Api.Client where
33
import Prelude
44

55
import Affjax (defaultRequest)
6-
import Affjax as Affjax
6+
import Affjax.Web as Affjax
77
import Affjax.RequestBody as RequestBody
88
import Affjax.RequestHeader (RequestHeader(..))
99
import Affjax.ResponseFormat as ResponseFormat

src/Conduit/AppM.purs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,20 @@ import Data.Either (Either)
3333
import Data.Foldable (for_)
3434
import Data.HTTP.Method (Method(..))
3535
import Data.Maybe (Maybe(..))
36-
import Data.Symbol (SProxy(..))
3736
import Effect.Aff (Aff)
3837
import Effect.Aff.Class (class MonadAff)
3938
import Effect.Class (class MonadEffect, liftEffect)
4039
import Effect.Exception as Exception
4140
import React.Halo as Halo
4241
import Record as Record
42+
import Type.Proxy (Proxy(..))
4343

4444
type Env =
4545
{ auth :: AuthIO
4646
, routing :: RoutingIO
4747
}
4848

49-
newtype AppM a
50-
= AppM (ReaderT Env Aff a)
49+
newtype AppM a = AppM (ReaderT Env Aff a)
5150

5251
runAppM :: Env -> AppM ~> Aff
5352
runAppM env (AppM m) = runReaderT m env
@@ -103,17 +102,17 @@ instance UserRepository AppM where
103102
loginUser credentials = do
104103
(res :: Either Error { user :: CurrentUser }) <- makeRequest POST (StatusCode 200) Endpoint.Login loginBodyCodec userResponseCodec { user: credentials }
105104
for_ res \{ user: currentUser } -> do
106-
Auth.modify $ const $ toAuth currentUser.token (Just $ Record.delete (SProxy :: _ "token") currentUser)
105+
Auth.modify $ const $ toAuth currentUser.token (Just $ Record.delete (Proxy :: _ "token") currentUser)
107106
pure $ res <#> _.user
108107
registerUser user = do
109108
(res :: Either Error { user :: CurrentUser }) <- makeRequest POST (StatusCode 200) Endpoint.Users registerBodyCodec userResponseCodec { user }
110109
for_ res \{ user: currentUser } -> do
111-
Auth.modify $ const $ toAuth currentUser.token (Just $ Record.delete (SProxy :: _ "token") currentUser)
110+
Auth.modify $ const $ toAuth currentUser.token (Just $ Record.delete (Proxy :: _ "token") currentUser)
112111
pure $ res <#> _.user
113112
updateUser user = do
114113
(res :: Either Error { user :: CurrentUser }) <- makeSecureRequest PUT (StatusCode 200) Endpoint.User updateUserBodyCodec userResponseCodec { user }
115114
for_ res \{ user: currentUser } -> do
116-
Auth.modify $ map $ _ { user = Just $ Record.delete (SProxy :: _ "token") currentUser }
115+
Auth.modify $ map $ _ { user = Just $ Record.delete (Proxy :: _ "token") currentUser }
117116
pure $ res <#> _.user
118117
logoutUser = do
119118
void $ Auth.modify $ const Nothing

src/Conduit/Assets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
exports.smileyCyrus = require("../../assets/smiley-cyrus.jpg");
1+
export { default as smileyCyrus } from "../../assets/smiley-cyrus.jpg";

src/Conduit/Capability/Auth.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class
1515
getEmitter :: m (HS.Emitter (Maybe Auth))
1616
modify :: (Maybe Auth -> Maybe Auth) -> m (Maybe Auth)
1717

18-
instance MonadAuth m => MonadAuth (HaloM props ctx state action m) where
18+
instance MonadAuth m => MonadAuth (HaloM props state action m) where
1919
read = lift read
2020
getEmitter = lift getEmitter
2121
modify = lift <<< modify
2222

23-
subscribe :: forall m props ctx state action. MonadAuth m => (Maybe Auth -> action) -> HaloM props ctx state action m Unit
23+
subscribe :: forall m props state action. MonadAuth m => (Maybe Auth -> action) -> HaloM props state action m Unit
2424
subscribe f = do
2525
emitter <- lift getEmitter
2626
void $ Halo.subscribe $ f <$> emitter

src/Conduit/Capability/Halo.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ import React.Halo (ComponentSpec)
1010
class
1111
Monad m <=
1212
MonadHalo m where
13-
component :: forall hooks props ctx state action. String -> ComponentSpec hooks props ctx state action m -> m (props -> JSX)
13+
component :: forall props state action. String -> ComponentSpec props state action m -> m (props -> JSX)

src/Conduit/Capability/Resource/Article.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class
1919
deleteArticle :: Slug -> m (Either Error Unit)
2020
toggleFavorite :: Article -> m (Either Error Article)
2121

22-
instance ArticleRepository m => ArticleRepository (HaloM props ctx state action m) where
22+
instance ArticleRepository m => ArticleRepository (HaloM props state action m) where
2323
listArticles = lift <<< listArticles
2424
listFeed = lift <<< listFeed
2525
getArticle = lift <<< getArticle

src/Conduit/Capability/Resource/Comment.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class
1515
createComment :: Slug -> { body :: String } -> m (Either Error Comment)
1616
deleteComment :: Slug -> CommentId -> m (Either Error Unit)
1717

18-
instance CommentRepository m => CommentRepository (HaloM props ctx state action m) where
18+
instance CommentRepository m => CommentRepository (HaloM props state action m) where
1919
listComments = lift <<< listComments
2020
createComment = \a b -> lift $ createComment a b
2121
deleteComment = \a b -> lift $ deleteComment a b

src/Conduit/Capability/Resource/Profile.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ class
1414
getProfile :: Username -> m (Either Error Profile)
1515
toggleFollow :: Profile -> m (Either Error Profile)
1616

17-
instance ProfileRepository m => ProfileRepository (HaloM props ctx state action m) where
17+
instance ProfileRepository m => ProfileRepository (HaloM props state action m) where
1818
getProfile = lift <<< getProfile
1919
toggleFollow = lift <<< toggleFollow

src/Conduit/Capability/Resource/Tag.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ class
1111
TagRepository m where
1212
listTags :: m (Either Error (Array String))
1313

14-
instance TagRepository m => TagRepository (HaloM props ctx state action m) where
14+
instance TagRepository m => TagRepository (HaloM props state action m) where
1515
listTags = lift listTags

src/Conduit/Capability/Resource/User.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class
1616
updateUser :: { | UserRep (password :: String) } -> m (Either Error CurrentUser)
1717
logoutUser :: m Unit
1818

19-
instance UserRepository m => UserRepository (HaloM props ctx state action m) where
19+
instance UserRepository m => UserRepository (HaloM props state action m) where
2020
loginUser = lift <<< loginUser
2121
registerUser = lift <<< registerUser
2222
updateUser = lift <<< updateUser

src/Conduit/Capability/Routing.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class
1515
navigate :: Route -> m Unit
1616
redirect :: Route -> m Unit
1717

18-
instance MonadRouting m => MonadRouting (HaloM props ctx state action m) where
18+
instance MonadRouting m => MonadRouting (HaloM props state action m) where
1919
read = lift read
2020
getEmitter = lift getEmitter
2121
navigate = lift <<< navigate
2222
redirect = lift <<< redirect
2323

24-
subscribe :: forall m props ctx state action. MonadRouting m => (Route -> action) -> HaloM props ctx state action m Unit
24+
subscribe :: forall m props state action. MonadRouting m => (Route -> action) -> HaloM props state action m Unit
2525
subscribe f = do
2626
emitter <- lift getEmitter
2727
void $ Halo.subscribe $ f <$> emitter

src/Conduit/Component/Auth.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Data.Either (Either, hush)
1212
import Data.Foldable (for_, traverse_)
1313
import Data.HTTP.Method (Method(..))
1414
import Data.Maybe (Maybe(..))
15-
import Data.Symbol (SProxy(..))
1615
import Data.Tuple.Nested (type (/\), (/\))
1716
import Effect (Effect)
1817
import Effect.Aff (launchAff_)
@@ -23,6 +22,7 @@ import Foreign.Day (now)
2322
import Halogen.Subscription as HS
2423
import React.Basic.Hooks as React
2524
import Record as Record
25+
import Type.Proxy (Proxy(..))
2626
import Web.HTML (window)
2727
import Web.HTML.Window as Window
2828
import Web.Storage.Storage as Storage
@@ -92,4 +92,4 @@ mkAuthManager = do
9292
(res :: Either Error { user :: CurrentUser }) <- makeSecureRequest' token GET (StatusCode 200) Endpoint.User CA.null (CAR.object "UserResponse" { user: currentUserCodec }) unit
9393
liftEffect case hush $ _.user <$> res of
9494
Nothing -> void $ modify $ const Nothing
95-
Just user -> void $ modify $ const $ toAuth user.token (Just $ Record.delete (SProxy :: SProxy "token") user)
95+
Just user -> void $ modify $ const $ toAuth user.token (Just $ Record.delete (Proxy :: Proxy "token") user)

src/Conduit/Component/Routing.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import React.Basic.Hooks as React
1111
import Routing.Duplex (parse, print)
1212
import Routing.PushState as PushState
1313
import Web.Router as Router
14-
import Web.Router.Driver.PushState as Driver
14+
import Web.Router.PushState as Driver
1515

1616
type RoutingIO =
1717
{ read :: Effect Route
@@ -27,9 +27,9 @@ mkRoutingManager = do
2727
value <- Ref.new $ either (const Error) identity $ parse routeCodec path
2828
{ emitter, listener } <- HS.create
2929
let
30-
driver = Driver.makeDriver_ (parse routeCodec) (print routeCodec) interface
30+
driver = Driver.mkInterface_ (parse routeCodec) (print routeCodec) interface
3131
router <-
32-
Router.makeRouter
32+
Router.mkInterface
3333
(\_ _ -> Router.continue)
3434
( case _ of
3535
Router.Resolved _ route -> do

src/Conduit/Config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
exports.apiEndpoint = process.env.API_ENDPOINT || "";
1+
export const apiEndpoint = process.env.API_ENDPOINT || "";
22

3-
exports.nodeEnv = process.env.NODE_ENV || "";
3+
export const nodeEnv = process.env.NODE_ENV || "";

src/Conduit/Data/Avatar.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import Data.Codec.Argonaut as CA
88
import Data.Maybe (Maybe(..))
99
import Data.String as String
1010

11-
newtype Avatar
12-
= Avatar String
11+
newtype Avatar = Avatar String
1312

1413
derive instance Eq Avatar
1514

src/Conduit/Data/Comment.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ type Comment =
1818
, author :: Profile
1919
}
2020

21-
newtype CommentId
22-
= CommentId Int
21+
newtype CommentId = CommentId Int
2322

2423
derive instance Newtype CommentId _
2524

src/Conduit/Data/Slug.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import Data.String.Regex as Regex
1010
import Data.String.Regex.Flags as Flags
1111
import Partial.Unsafe (unsafePartial)
1212

13-
newtype Slug
14-
= Slug String
13+
newtype Slug = Slug String
1514

1615
derive instance Eq Slug
1716

src/Conduit/Data/Username.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import Data.Codec.Argonaut (JsonCodec)
66
import Data.Codec.Argonaut as CA
77
import Data.Maybe (Maybe(..))
88

9-
newtype Username
10-
= Username String
9+
newtype Username = Username String
1110

1211
derive instance Eq Username
1312

src/Conduit/Form/Validated.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ _Modified =
5151
_ -> Nothing
5252

5353
-- | Mapping instance
54-
newtype ModifyValidated
55-
= ModifyValidated (Validated ~> Validated)
54+
newtype ModifyValidated = ModifyValidated (Validated ~> Validated)
5655

5756
instance Mapping ModifyValidated a a => Mapping ModifyValidated (Validated a) (Validated a) where
5857
mapping m@(ModifyValidated f) = over _Validated (mapping m) <<< f

src/Conduit/Page/Article.purs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import Data.Lens (preview, set)
3131
import Data.Lens.Record as LR
3232
import Data.Maybe (Maybe(..), maybe)
3333
import Data.Monoid (guard)
34-
import Data.Symbol (SProxy(..))
3534
import Data.Validation.Semigroup (V, toEither)
3635
import Foreign.Day (toDisplay)
3736
import Foreign.NanoMarkdown (nmd)
@@ -42,6 +41,7 @@ import React.Basic.DOM.Events (preventDefault, targetValue)
4241
import React.Basic.Events (handler, handler_)
4342
import React.Basic.Hooks as React
4443
import React.Halo as Halo
44+
import Type.Proxy (Proxy(..))
4545

4646
type Props =
4747
{ slug :: Slug
@@ -70,11 +70,9 @@ mkArticlePage ::
7070
ProfileRepository m =>
7171
MonadHalo m =>
7272
m (Props -> React.JSX)
73-
mkArticlePage = component "ArticlePage" { context, initialState, eval, render }
73+
mkArticlePage = component "ArticlePage" { initialState, eval, render }
7474
where
75-
context _ = pure unit
76-
77-
initialState _ _ =
75+
initialState _ =
7876
{ auth: Nothing
7977
, article: RemoteData.NotAsked
8078
, comments: RemoteData.NotAsked
@@ -84,9 +82,9 @@ mkArticlePage = component "ArticlePage" { context, initialState, eval, render }
8482

8583
eval =
8684
Halo.mkEval
87-
_
85+
Halo.defaultEval
8886
{ onInitialize = \_ -> Just Initialize
89-
, onUpdate = \prev next -> Just $ OnPropsUpdate prev.props next.props
87+
, onUpdate = \prev next -> Just $ OnPropsUpdate prev next
9088
, onAction = handleAction
9189
}
9290

@@ -158,7 +156,7 @@ mkArticlePage = component "ArticlePage" { context, initialState, eval, render }
158156

159157
validate :: forall r. { body :: Validated String | r } -> V { body :: Array String } { body :: String }
160158
validate values = ado
161-
body <- values.body # V.validated (LR.prop (SProxy :: _ "body")) F.nonEmpty
159+
body <- values.body # V.validated (LR.prop (Proxy :: _ "body")) F.nonEmpty
162160
in { body }
163161

164162
render { state, send } =

0 commit comments

Comments
 (0)