git.iko.soy/typeable/http-api-data
on master help sign in
Update README
commitc5817980ea48ad3c2276eedcb60254c135ae1458 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateSun 4 Oct 2015, 03:18 (11 years ago) parent6047a63
1 file changed+46−4
README.md+46−4
README.md+46−4
@@ -1,6 +1,48 @@
1−## path-pieces
1+# http-api-data
22
3−Defines two typeclasses used for converting Haskell data types to and from route pieces.
4−Used in Yesod to automatically marshall data in the request path.
3+This package defines typeclasses used for converting Haskell data types to and from HTTP API data.
4+
5+### Examples
6+
7+Booleans:
8+
9+```
10+>>> toUrlPiece True
11+"True"
12+>>> parseUrlPiece "False" :: Either Text Bool
13+Right False
14+>>> parseUrlPiece "something else" :: Either Text Bool
15+Left "could not convert: `something else'"
16+```
17+
18+Numbers:
19+
20+```
21+>>> toUrlPiece 45.2
22+"45.2"
23+>>> parseUrlPiece "452" :: Either Text Int
24+Right 452
25+```
26+
27+Strings:
28+
29+```
30+>>> toHeader "hello"
31+"hello"
32+>>> parseHeader "world" :: Either Text String
33+Right "world"
34+```
35+
36+Calendar day:
37+
38+```
39+>>> toQueryParam (fromGregorian 2015 10 03)
40+"2015-10-03"
41+>>> toGregorian <$> parseQueryParam "2016-12-01"
42+Right (2016,12,1)
43+```
44+
45+## Contributing
46+
47+Contributions and bug reports are welcome!
548
6−see http://www.yesodweb.com/ for more information.