git.iko.soy/typeable/http-api-data
on master help sign in
Update examples
commit88764aefa4f7b55a1975ff52d63e7b63e2fe3c49 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateMon 12 Oct 2015, 13:01 (11 years ago) parent397b129
2 files changed+19−14
README.md+10−8 Web/HttpApiData.hs+9−6
README.md+10−8
@@ -11,22 +11,24 @@ Booleans:
1111
1212```
1313>>> toUrlPiece True
14−"True"
15−>>> parseUrlPiece "False" :: Either Text Bool
14+"true"
15+>>> parseUrlPiece "false" :: Either Text Bool
1616Right False
17−>>> parseUrlPiece "something else" :: Either Text Bool
18−Left "could not parse: `something else'"
17+>>> parseUrlPieces ["true", "false", "undefined"] :: Either Text [Bool]
18+Left "could not parse: `undefined'"
1919```
2020
2121Numbers:
2222
2323```
24−>>> toUrlPiece 45.2
24+>>> toQueryParam 45.2
2525"45.2"
26−>>> parseUrlPiece "452" :: Either Text Int
26+>>> parseQueryParam "452" :: Either Text Int
2727Right 452
28−>>> parseUrlPiece "256" :: Either Text Int8
29−Left "out of bounds: `256' (should be between -128 and 127)"
28+>>> toQueryParams [1..5]
29+["1","2","3","4","5"]
30+>>> parseQueryParams ["127", "255"] :: Either Text [Int8]
31+Left "out of bounds: `255' (should be between -128 and 127)"
3032```
3133
3234Strings:
Web/HttpApiData.hs+9−6
@@ -53,17 +53,19 @@ import Web.HttpApiData.Internal
5353-- "true"
5454-- >>> parseUrlPiece "false" :: Either Text Bool
5555-- Right False
56−-- >>> parseUrlPiece "something else" :: Either Text Bool
57−-- Left "could not parse: `something else'"
56+-- >>> parseUrlPieces ["true", "false", "undefined"] :: Either Text [Bool]
57+-- Left "could not parse: `undefined'"
5858--
5959-- Numbers:
6060--
61−-- >>> toUrlPiece 45.2
61+-- >>> toQueryParam 45.2
6262-- "45.2"
63−-- >>> parseUrlPiece "452" :: Either Text Int
63+-- >>> parseQueryParam "452" :: Either Text Int
6464-- Right 452
65−-- >>> parseUrlPiece "256" :: Either Text Int8
66−-- Left "out of bounds: `256' (should be between -128 and 127)"
65+-- >>> toQueryParams [1..5]
66+-- ["1","2","3","4","5"]
67+-- >>> parseQueryParams ["127", "255"] :: Either Text [Int8]
68+-- Left "out of bounds: `255' (should be between -128 and 127)"
6769--
6870-- Strings:
6971--
@@ -78,3 +80,4 @@ import Web.HttpApiData.Internal
7880-- "2015-10-03"
7981-- >>> toGregorian <$> parseQueryParam "2016-12-01"
8082-- Right (2016,12,1)
83+