git.iko.soy/typeable/http-api-data
on 8dc43fe help sign in
50 lines 881 B history raw
1# http-api-data
3[![Build Status](https://secure.travis-ci.org/fizruk/http-api-data.png?branch=master)](http://travis-ci.org/fizruk/http-api-data)
5This package defines typeclasses used for converting Haskell data types to and from HTTP API data.
7### Examples
9Booleans:
11```
12>>> toUrlPiece True
13"True"
14>>> parseUrlPiece "False" :: Either Text Bool
15Right False
16>>> parseUrlPiece "something else" :: Either Text Bool
17Left "could not convert: `something else'"
18```
20Numbers:
22```
23>>> toUrlPiece 45.2
24"45.2"
25>>> parseUrlPiece "452" :: Either Text Int
26Right 452
27```
29Strings:
31```
32>>> toHeader "hello"
33"hello"
34>>> parseHeader "world" :: Either Text String
35Right "world"
36```
38Calendar day:
40```
41>>> toQueryParam (fromGregorian 2015 10 03)
42"2015-10-03"
43>>> toGregorian <$> parseQueryParam "2016-12-01"
44Right (2016,12,1)
45```
47## Contributing
49Contributions and bug reports are welcome!