Skip to content

Commit 0f56271

Browse files
authored
Merge pull request #58 from safareli/patch-1
Restore comments from Routing.Match.Class
2 parents 588d484 + f0dbd2f commit 0f56271

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Routing/Match.purs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ instance matchApplicative :: Applicative Match where
5656
root :: Match Unit
5757
root = lit ""
5858

59+
-- | `lit x` will match exactly the path component `x`.
60+
-- | For example, `lit "x"` matches `/x`.
5961
lit :: String -> Match Unit
6062
lit 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.
6972
num :: Match Number
7073
num = 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.
8185
int :: Match Int
8286
int = 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.
9095
bool :: Match Boolean
9196
bool = 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"`.
100107
str :: Match String
101108
str = 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"`.
108117
param :: String -> Match String
109118
param 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*.
120133
params :: Match (M.Map String String)
121134
params = 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.
128142
end :: Match Unit
129143
end = Match \route ->
130144
case route of

0 commit comments

Comments
 (0)