git.iko.soy/typeable/http-api-data
on v0.1.1 help sign in
53 lines 1.1 kB history raw
1# http-api-data
3[![Hackage package](http://img.shields.io/hackage/v/http-api-data.svg)](http://hackage.haskell.org/package/http-api-data)
4[![Build Status](https://secure.travis-ci.org/fizruk/http-api-data.png?branch=master)](http://travis-ci.org/fizruk/http-api-data)
6This package defines typeclasses used for converting Haskell data types to and from HTTP API data.
8### Examples
10Booleans:
12```
13>>> toUrlPiece True
14"True"
15>>> parseUrlPiece "False" :: Either Text Bool
16Right False
17>>> parseUrlPiece "something else" :: Either Text Bool
18Left "could not parse: `something else'"
19```
21Numbers:
23```
24>>> toUrlPiece 45.2
25"45.2"
26>>> parseUrlPiece "452" :: Either Text Int
27Right 452
28>>> parseUrlPiece "256" :: Either Text Int8
29Left "out of bounds: `256' (should be between -128 and 127)"
30```
32Strings:
34```
35>>> toHeader "hello"
36"hello"
37>>> parseHeader "world" :: Either Text String
38Right "world"
39```
41Calendar day:
43```
44>>> toQueryParam (fromGregorian 2015 10 03)
45"2015-10-03"
46>>> toGregorian <$> parseQueryParam "2016-12-01"
47Right (2016,12,1)
48```
50## Contributing
52Contributions and bug reports are welcome!