From 7a944f2a5cd2436e6bd7b2264f4ccb7be331b05b Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 4 Dec 2020 12:42:33 -0800 Subject: [PATCH 1/8] Update packages.dhall to prepare-0.14 bootstrap --- packages.dhall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.dhall b/packages.dhall index 80f5fe6..9c3ee6f 100644 --- a/packages.dhall +++ b/packages.dhall @@ -1,4 +1,4 @@ let upstream = - https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20201007/packages.dhall sha256:35633f6f591b94d216392c9e0500207bb1fec42dd355f4fecdfd186956567b6b + https://raw.githubusercontent.com/purescript/package-sets/prepare-0.14/src/packages.dhall in upstream From 66acd18fab4af6b370556ce353897ccedbae8b79 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 4 Dec 2020 12:42:33 -0800 Subject: [PATCH 2/8] Update CI to use v0.14.0-rc3 PS release --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b0550f..d91f17d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,8 @@ jobs: - name: Set up a PureScript toolchain uses: purescript-contrib/setup-purescript@main + with: + purescript: "0.14.0-rc3" - name: Cache PureScript dependencies uses: actions/cache@v2 From 2123940af384b25cf098897604c571ed287affee Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 4 Dec 2020 12:42:33 -0800 Subject: [PATCH 3/8] Update dependency on 'globals' to 'numbers'' --- spago.dhall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spago.dhall b/spago.dhall index fef4177..9af9b91 100644 --- a/spago.dhall +++ b/spago.dhall @@ -8,7 +8,7 @@ , "either" , "foldable-traversable" , "generics-rep" - , "globals" + , "numbers" , "integers" , "lists" , "maybe" From 7c8d10fa56ca1d107fb5856def28bae232541e35 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 4 Dec 2020 12:48:02 -0800 Subject: [PATCH 4/8] Update code to use numbers for isNaN and readFloat --- src/Routing/Match.purs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Routing/Match.purs b/src/Routing/Match.purs index 3ed35ef..a99a9a6 100644 --- a/src/Routing/Match.purs +++ b/src/Routing/Match.purs @@ -17,7 +17,7 @@ import Data.String.NonEmpty (NonEmptyString) import Data.String.NonEmpty as NES import Data.Tuple (Tuple(..), snd) import Data.Validation.Semiring (V, invalid, unV) -import Global (readFloat, isNaN) +import Data.Number as Number import Routing.Match.Error (MatchError(..), showMatchError) import Routing.Types (Route, RoutePart(..)) @@ -70,11 +70,9 @@ num :: Match Number num = Match \route -> case route of Cons (Path input) rs -> - let res = readFloat input in - if isNaN res then - invalid $ free ExpectedNumber - else - pure $ Tuple rs res + case Number.fromString input of + Just res | not (Number.isNaN res) -> pure $ Tuple rs res + _ -> invalid $ free ExpectedNumber _ -> invalid $ free ExpectedNumber From 2b4ad7be80ab9d4b8390469841cf0beb7e9a7fb4 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Fri, 4 Dec 2020 12:48:12 -0800 Subject: [PATCH 5/8] Comment out Globals usage --- src/Routing.purs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Routing.purs b/src/Routing.purs index 1f0cc90..4af91e9 100644 --- a/src/Routing.purs +++ b/src/Routing.purs @@ -6,7 +6,7 @@ module Routing import Prelude import Data.Either (Either) -import Global.Unsafe (unsafeDecodeURIComponent) +-- import Global.Unsafe (unsafeDecodeURIComponent) import Routing.Match (Match, runMatch) import Routing.Parser (parse) From 3dbb312722140d732a12d2daaf76cfa9d159d636 Mon Sep 17 00:00:00 2001 From: Miles Frain Date: Wed, 16 Dec 2020 13:23:45 -0800 Subject: [PATCH 6/8] Incorporate JSURI --- spago.dhall | 4 +++- src/Routing.purs | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spago.dhall b/spago.dhall index 9af9b91..5da067e 100644 --- a/spago.dhall +++ b/spago.dhall @@ -8,10 +8,12 @@ , "either" , "foldable-traversable" , "generics-rep" - , "numbers" , "integers" + , "js-uri" , "lists" , "maybe" + , "numbers" + , "partial" , "prelude" , "psci-support" , "record" diff --git a/src/Routing.purs b/src/Routing.purs index 4af91e9..d0530eb 100644 --- a/src/Routing.purs +++ b/src/Routing.purs @@ -6,10 +6,16 @@ module Routing import Prelude import Data.Either (Either) --- import Global.Unsafe (unsafeDecodeURIComponent) +import Data.Maybe (fromJust) +import JSURI (decodeURIComponent) +import Partial.Unsafe(unsafePartial) import Routing.Match (Match, runMatch) import Routing.Parser (parse) +unsafeDecodeURIComponent :: String -> String +unsafeDecodeURIComponent uri = + unsafePartial $ fromJust $ decodeURIComponent uri + -- | Runs a `Match` parser. match :: forall a. Match a -> String -> Either String a match = matchWith unsafeDecodeURIComponent From e75a7d61bc3f86a4f590b370f8c0de18baaefda0 Mon Sep 17 00:00:00 2001 From: Miles Frain Date: Wed, 16 Dec 2020 13:55:57 -0800 Subject: [PATCH 7/8] update bower.json to point to latest lib versions --- bower.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/bower.json b/bower.json index d11c70b..dfa0972 100644 --- a/bower.json +++ b/bower.json @@ -24,26 +24,26 @@ "package.json" ], "dependencies": { - "purescript-web-html": "^2.0.0", - "purescript-effect": "^2.0.0", - "purescript-either": "^4.0.0", - "purescript-globals": "^4.0.0", - "purescript-lists": "^5.0.0", - "purescript-maybe": "^4.0.0", - "purescript-prelude": "^4.0.0", - "purescript-semirings": "^5.0.0", - "purescript-tuples": "^5.0.0", - "purescript-validation": "^4.0.0", - "purescript-aff": "^5.0.0", - "purescript-control": "^4.0.0", - "purescript-console": "^4.1.0", - "purescript-integers": "^4.0.0", - "purescript-foldable-traversable": "^4.0.0" + "purescript-web-html": "master", + "purescript-effect": "master", + "purescript-either": "master", + "purescript-lists": "master", + "purescript-maybe": "master", + "purescript-prelude": "master", + "purescript-semirings": "master", + "purescript-tuples": "master", + "purescript-validation": "master", + "purescript-aff": "master", + "purescript-control": "master", + "purescript-console": "master", + "purescript-integers": "master", + "purescript-js-uri": "https://github.com/purescript-contrib/purescript-js-uri.git#main", + "purescript-foldable-traversable": "master" }, "devDependencies": { - "purescript-console": "^4.1.0", - "purescript-assert": "^4.0.0", - "purescript-record": "^2.0.0", - "purescript-generics-rep": "^6.0.0" + "purescript-console": "master", + "purescript-assert": "master", + "purescript-record": "master", + "purescript-generics-rep": "master" } } From 25358da1b9bde001285a0c1ffd89fa5dce3c3b92 Mon Sep 17 00:00:00 2001 From: Miles Frain Date: Wed, 16 Dec 2020 14:40:15 -0800 Subject: [PATCH 8/8] Remove helper function --- src/Routing.purs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Routing.purs b/src/Routing.purs index d0530eb..bd7b5a8 100644 --- a/src/Routing.purs +++ b/src/Routing.purs @@ -12,13 +12,9 @@ import Partial.Unsafe(unsafePartial) import Routing.Match (Match, runMatch) import Routing.Parser (parse) -unsafeDecodeURIComponent :: String -> String -unsafeDecodeURIComponent uri = - unsafePartial $ fromJust $ decodeURIComponent uri - -- | Runs a `Match` parser. match :: forall a. Match a -> String -> Either String a -match = matchWith unsafeDecodeURIComponent +match = matchWith $ unsafePartial fromJust <<< decodeURIComponent -- | Runs a `Match` parser given a custom String decoder. matchWith :: forall a. (String -> String) -> Match a -> String -> Either String a