Skip to content

Rename matchHash and matchHash' #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Routing.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module Routing (
hashes,
matches,
matches',
matchHash,
matchHash',
match,
matchWith,
matchesAff,
matchesAff'
) where
Expand Down Expand Up @@ -46,7 +46,7 @@ matches = matches' decodeURIComponent
matches' :: forall e a. (String -> String) ->
Match a -> (Maybe a -> a -> Eff e Unit) -> Eff e Unit
matches' decoder routing cb = hashes $ \old new ->
let mr = matchHash' decoder routing
let mr = matchWith decoder routing
fst = either (const Nothing) Just $ mr old
in either (const $ pure unit) (cb fst) $ mr new

Expand All @@ -61,8 +61,8 @@ matchesAff :: forall e a. Match a -> Aff e (Tuple (Maybe a) a)
matchesAff = matchesAff' decodeURIComponent


matchHash :: forall a. Match a -> String -> Either String a
matchHash = matchHash' decodeURIComponent
match :: forall a. Match a -> String -> Either String a
match = matchWith decodeURIComponent

matchHash' :: forall a. (String -> String) -> Match a -> String -> Either String a
matchHash' decoder matcher hash = runMatch matcher $ parse decoder hash
matchWith :: forall a. (String -> String) -> Match a -> String -> Either String a
matchWith decoder matcher hash = runMatch matcher $ parse decoder hash
6 changes: 3 additions & 3 deletions test/Test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Data.List (List)
import Data.Map as M


import Routing (matchHash)
import Routing (match)
import Routing.Match (Match, list)
import Routing.Match.Class (num, int, param, bool, lit, params)

Expand All @@ -34,8 +34,8 @@ routing =

main :: Eff (console :: CONSOLE) Unit
main = do
logShow $ matchHash routing "foo/12/?welp='hi'&b=false"
logShow $ matchHash routing "/quux/42"
logShow $ match routing "foo/12/?welp='hi'&b=false"
logShow $ match routing "/quux/42"

-- (minimal test for browser)

Expand Down