1
1
module Test.Main where
2
2
3
- import Prelude (class Show , Unit , show , ($), (<$>), (*>), (<*>), (<>))
3
+ import Prelude (class Show , Unit , bind , show , ($), (<$>), (*>), (<*>), (<>))
4
4
import Control.Monad.Eff (Eff )
5
5
import Control.Monad.Eff.Console (CONSOLE (), logShow )
6
6
import Control.Alt ((<|>))
@@ -10,25 +10,32 @@ import Data.Map as M
10
10
11
11
import Routing (matchHash )
12
12
import Routing.Match (Match , list )
13
- import Routing.Match.Class (num , param , bool , lit , params )
13
+ import Routing.Match.Class (num , int , param , bool , lit , params )
14
14
15
- data FooBar = Foo Number (M.Map String String ) | Bar Boolean String | Baz (List Number )
15
+ data FooBar
16
+ = Foo Number (M.Map String String )
17
+ | Bar Boolean String
18
+ | Baz (List Number )
19
+ | Quux Int
16
20
17
21
instance showFooBar :: Show FooBar where
18
22
show (Foo num q) = " (Foo " <> show num <> " " <> show q <> " )"
19
23
show (Bar bool str) = " (Bar " <> show bool <> " " <> show str <> " )"
20
24
show (Baz lst) = " (Baz " <> show lst <> " )"
25
+ show (Quux i) = " (Quux " <> show i <> " )"
21
26
22
27
routing :: Match FooBar
23
28
routing =
24
29
Foo <$> (lit " foo" *> num) <*> params
25
30
<|> Bar <$> (lit " bar" *> bool) <*> (param " baz" )
31
+ <|> Quux <$> (lit " " *> lit " quux" *> int)
26
32
<|> Baz <$> (list num)
27
33
28
34
29
35
main :: Eff (console :: CONSOLE ) Unit
30
36
main = do
31
37
logShow $ matchHash routing " foo/12/?welp='hi'&b=false"
38
+ logShow $ matchHash routing " /quux/42"
32
39
33
40
-- (minimal test for browser)
34
41
0 commit comments