git.iko.soy/typeable/http-api-data
on master help sign in
Update examples
88764aeNickolay Kudasov
README.md+10−8
@@ -11,22 +11,24 @@ Booleans:
11
11
12```
12```
13>>> toUrlPiece True
13>>> toUrlPiece True
14−"True"
14+"true"
15−>>> parseUrlPiece "False" :: Either Text Bool
15+>>> parseUrlPiece "false" :: Either Text Bool
16Right False
16Right False
17−>>> parseUrlPiece "something else" :: Either Text Bool
17+>>> parseUrlPieces ["true", "false", "undefined"] :: Either Text [Bool]
18−Left "could not parse: `something else'"
18+Left "could not parse: `undefined'"
19```
19```
20
20
21Numbers:
21Numbers:
22
22
23```
23```
24−>>> toUrlPiece 45.2
24+>>> toQueryParam 45.2
25"45.2"
25"45.2"
26−>>> parseUrlPiece "452" :: Either Text Int
26+>>> parseQueryParam "452" :: Either Text Int
27Right 452
27Right 452
28+>>> toQueryParams [1..5]
29+["1","2","3","4","5"]
28−>>> parseUrlPiece "256" :: Either Text Int8
30+>>> parseQueryParams ["127", "255"] :: Either Text [Int8]
29−Left "out of bounds: `256' (should be between -128 and 127)"
31+Left "out of bounds: `255' (should be between -128 and 127)"
30```
32```
31
33
32Strings:
34Strings:
Web/HttpApiData.hs+9−6
@@ -53,17 +53,19 @@ import Web.HttpApiData.Internal
53-- "true"
53-- "true"
54-- >>> parseUrlPiece "false" :: Either Text Bool
54-- >>> parseUrlPiece "false" :: Either Text Bool
55-- Right False
55-- Right False
56−-- >>> parseUrlPiece "something else" :: Either Text Bool
56+-- >>> parseUrlPieces ["true", "false", "undefined"] :: Either Text [Bool]
57−-- Left "could not parse: `something else'"
57+-- Left "could not parse: `undefined'"
58--
58--
59-- Numbers:
59-- Numbers:
60--
60--
61−-- >>> toUrlPiece 45.2
61+-- >>> toQueryParam 45.2
62-- "45.2"
62-- "45.2"
63−-- >>> parseUrlPiece "452" :: Either Text Int
63+-- >>> parseQueryParam "452" :: Either Text Int
64-- Right 452
64-- Right 452
65+-- >>> toQueryParams [1..5]
66+-- ["1","2","3","4","5"]
65−-- >>> parseUrlPiece "256" :: Either Text Int8
67+-- >>> parseQueryParams ["127", "255"] :: Either Text [Int8]
66−-- Left "out of bounds: `256' (should be between -128 and 127)"
68+-- Left "out of bounds: `255' (should be between -128 and 127)"
67--
69--
68-- Strings:
70-- Strings:
69--
71--
@@ -78,3 +80,4 @@ import Web.HttpApiData.Internal
78-- "2015-10-03"
80-- "2015-10-03"
79-- >>> toGregorian <$> parseQueryParam "2016-12-01"
81-- >>> toGregorian <$> parseQueryParam "2016-12-01"
80-- Right (2016,12,1)
82-- Right (2016,12,1)
83+