Skip to content

Commit 34963d5

Browse files
author
Colin Wahl
authored
Update for PureScript 0.14 (#21)
1 parent 150d92b commit 34963d5

File tree

6 files changed

+32
-27
lines changed

6 files changed

+32
-27
lines changed

bower.json

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
"output"
99
],
1010
"dependencies": {
11-
"purescript-prelude": "^4.1.0",
12-
"purescript-record": "^2.0.0",
13-
"purescript-generics-rep": "^6.0.0",
14-
"purescript-either": "^4.0.0",
15-
"purescript-control": "^4.1.0",
16-
"purescript-arrays": "^5.0.0",
17-
"purescript-globals": "^4.0.0",
18-
"purescript-strings": "^4.0.0",
19-
"purescript-lazy": "^4.0.0",
20-
"purescript-profunctor": "^4.0.0"
11+
"purescript-prelude": "^5.0.0",
12+
"purescript-record": "^3.0.0",
13+
"purescript-either": "^5.0.0",
14+
"purescript-control": "^5.0.0",
15+
"purescript-arrays": "^6.0.0",
16+
"purescript-strings": "^5.0.0",
17+
"purescript-lazy": "^5.0.0",
18+
"purescript-profunctor": "^5.0.0",
19+
"purescript-js-uri": "https://github.com/purescript-contrib/purescript-js-uri.git#2.0.0"
2120
},
2221
"devDependencies": {
23-
"purescript-psci-support": "^4.0.0",
24-
"purescript-console": "^4.1.0",
25-
"purescript-effect": "^2.0.0",
26-
"purescript-assert": "^4.0.0",
27-
"purescript-quickcheck": "^6.1.0"
22+
"purescript-psci-support": "^5.0.0",
23+
"purescript-console": "^5.0.0",
24+
"purescript-effect": "^3.0.0",
25+
"purescript-assert": "^5.0.0",
26+
"purescript-quickcheck": "^7.0.0"
2827
}
2928
}

src/Routing/Duplex.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import Data.String (Pattern(..))
4141
import Data.String as String
4242
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
4343
import Prim.Row as Row
44-
import Prim.RowList (kind RowList, class RowToList, Cons, Nil)
44+
import Prim.RowList (RowList, class RowToList, Cons, Nil)
4545
import Record as Record
4646
import Routing.Duplex.Parser (RouteParser)
4747
import Routing.Duplex.Parser as Parser
@@ -328,7 +328,7 @@ prop sym (RouteDuplex f g) (RouteDuplex x y) =
328328

329329
infix 2 prop as :=
330330

331-
class RouteDuplexParams (r1 :: # Type) (r2 :: # Type) | r1 -> r2 where
331+
class RouteDuplexParams (r1 :: Row Type) (r2 :: Row Type) | r1 -> r2 where
332332
-- | Builds a `RouteDuplex` from a record of query parameter parsers/printers, where
333333
-- | each property corresponds to a query parameter with the same name.
334334
-- |
@@ -353,7 +353,7 @@ instance routeDuplexParams ::
353353
record
354354
# buildParams (RLProxy :: RLProxy rl) r
355355

356-
class RouteDuplexBuildParams (rl :: RowList) (r1 :: # Type) (r2 :: # Type) (r3 :: # Type) (r4 :: # Type) | rl -> r1 r2 r3 r4 where
356+
class RouteDuplexBuildParams (rl :: RowList Type) (r1 :: Row Type) (r2 :: Row Type) (r3 :: Row Type) (r4 :: Row Type) | rl -> r1 r2 r3 r4 where
357357
buildParams ::
358358
RLProxy rl ->
359359
{ | r1 } ->

src/Routing/Duplex/Generic.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ sum :: forall a rep r.
1717
RouteDuplex' a
1818
sum = dimap from to <<< gRouteDuplex
1919

20-
class GRouteDuplex rep (r :: # Type) | rep -> r where
20+
class GRouteDuplex rep (r :: Row Type) | rep -> r where
2121
gRouteDuplex :: { | r } -> RouteDuplex' rep
2222

2323
instance gRouteSum ::

src/Routing/Duplex/Parser.purs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ import Data.Array.NonEmpty (NonEmptyArray)
3232
import Data.Array.NonEmpty as NEA
3333
import Data.Bifunctor (bimap, lmap)
3434
import Data.Either (Either(..))
35-
import Data.Foldable (foldl)
35+
import Data.Foldable (foldl, lookup)
3636
import Data.Generic.Rep (class Generic)
37-
import Data.Generic.Rep.Show (genericShow)
3837
import Data.Int as Int
3938
import Data.Lazy as Z
40-
import Data.Maybe (Maybe(..), maybe)
39+
import Data.Maybe (Maybe(..), fromJust, maybe)
40+
import Data.Show.Generic (genericShow)
4141
import Data.String (Pattern(..), split)
4242
import Data.String.CodeUnits as String
4343
import Data.Tuple (Tuple(..))
44-
import Data.Tuple as Tuple
45-
import Global.Unsafe (unsafeDecodeURIComponent)
44+
import JSURI (decodeURIComponent)
45+
import Partial.Unsafe (unsafePartial)
4646
import Routing.Duplex.Types (RouteParams, RouteState)
4747

4848
data RouteResult a
@@ -163,6 +163,8 @@ parsePath =
163163
splitAt (flip Tuple "") "?"
164164
>>> bimap splitSegments splitParams
165165

166+
unsafeDecodeURIComponent = unsafePartial fromJust <<< decodeURIComponent
167+
166168
splitSegments = splitNonEmpty (Pattern "/") >>> case _ of
167169
["", ""] -> [""]
168170
xs -> map unsafeDecodeURIComponent xs
@@ -200,7 +202,7 @@ take = Chomp \state ->
200202

201203
param :: String -> RouteParser String
202204
param key = Chomp \state ->
203-
case Tuple.lookup key state.params of
205+
case lookup key state.params of
204206
Just a -> Success state a
205207
_ -> Fail $ MissingParam key
206208

src/Routing/Duplex/Printer.purs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import Prelude
1212

1313
import Data.Array as Array
1414
import Data.Function (applyFlipped)
15+
import Data.Maybe (fromJust)
1516
import Data.Newtype (class Newtype, unwrap)
1617
import Data.String (joinWith)
1718
import Data.Tuple (Tuple(..), uncurry)
18-
import Global.Unsafe (unsafeEncodeURIComponent)
19+
import JSURI (encodeURIComponent)
20+
import Partial.Unsafe (unsafePartial)
1921
import Routing.Duplex.Types (RouteState, emptyRouteState)
2022

2123
newtype RoutePrinter = RoutePrinter (RouteState -> RouteState)
@@ -49,6 +51,8 @@ printPath :: RouteState -> String
4951
printPath { segments, params, hash: hash' } =
5052
printSegments segments <> printParams params <> printHash hash'
5153
where
54+
unsafeEncodeURIComponent = unsafePartial fromJust <<< encodeURIComponent
55+
5256
printSegments = case _ of
5357
[""] -> "/"
5458
xs -> joinWith "/" $ map unsafeEncodeURIComponent xs

test/Main.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Prelude hiding ((/))
44

55
import Data.Either (Either(..))
66
import Data.Generic.Rep (class Generic)
7-
import Data.Generic.Rep.Show (genericShow)
7+
import Data.Show.Generic (genericShow)
88
import Data.String.Gen (genAlphaString)
99
import Data.Symbol (SProxy(..))
1010
import Effect (Effect)

0 commit comments

Comments
 (0)