@@ -56,6 +56,8 @@ instance matchApplicative :: Applicative Match where
5656root :: Match Unit
5757root = lit " "
5858
59+ -- | `lit x` will match exactly the path component `x`.
60+ -- | For example, `lit "x"` matches `/x`.
5961lit :: String -> Match Unit
6062lit input = Match \route ->
6163 case route of
@@ -66,6 +68,7 @@ lit input = Match \route ->
6668 _ ->
6769 invalid $ free ExpectedPathPart
6870
71+ -- | `num` matches any numerical path component.
6972num :: Match Number
7073num = Match \route ->
7174 case route of
@@ -78,6 +81,7 @@ num = Match \route ->
7881 _ ->
7982 invalid $ free ExpectedNumber
8083
84+ -- | `int` matches any integer path component.
8185int :: Match Int
8286int = Match \route ->
8387 case route of
@@ -87,6 +91,7 @@ int = Match \route ->
8791 _ ->
8892 invalid $ free ExpectedInt
8993
94+ -- | `bool` matches any boolean path component.
9095bool :: Match Boolean
9196bool = Match \route ->
9297 case route of
@@ -97,6 +102,8 @@ bool = Match \route ->
97102 _ ->
98103 invalid $ free ExpectedBoolean
99104
105+ -- | `str` matches any path string component.
106+ -- | For example, `str` matches `/foo` as `"foo"`.
100107str :: Match String
101108str = Match \route ->
102109 case route of
@@ -105,6 +112,8 @@ str = Match \route ->
105112 _ ->
106113 invalid $ free ExpectedString
107114
115+ -- | `param p` matches a parameter assignment `q=v` within a query block.
116+ -- | For example, `param "q"` matches `/?q=a&r=b` as `"a"`.
108117param :: String -> Match String
109118param key = Match \route ->
110119 case route of
@@ -117,6 +126,10 @@ param key = Match \route ->
117126 _ ->
118127 invalid $ free ExpectedQuery
119128
129+ -- | `params` matches an entire query block. For exmaple, `params`
130+ -- | matches `/?q=a&r=b` as the map `{q : "a", r : "b"}`. Note that
131+ -- | `lit "foo" *> params` does *not* match `/foo`, since a query component
132+ -- | is *required*.
120133params :: Match (M.Map String String )
121134params = Match \route ->
122135 case route of
@@ -125,6 +138,7 @@ params = Match \route ->
125138 _ ->
126139 invalid $ free ExpectedQuery
127140
141+ -- | `end` matches the end of a route.
128142end :: Match Unit
129143end = Match \route ->
130144 case route of
0 commit comments