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 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" } } 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 diff --git a/spago.dhall b/spago.dhall index fef4177..5da067e 100644 --- a/spago.dhall +++ b/spago.dhall @@ -8,10 +8,12 @@ , "either" , "foldable-traversable" , "generics-rep" - , "globals" , "integers" + , "js-uri" , "lists" , "maybe" + , "numbers" + , "partial" , "prelude" , "psci-support" , "record" diff --git a/src/Routing.purs b/src/Routing.purs index 1f0cc90..bd7b5a8 100644 --- a/src/Routing.purs +++ b/src/Routing.purs @@ -6,13 +6,15 @@ 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) -- | 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 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