http-api-data

Converting to/from HTTP API data like URL pieces, headers and query parameters.

http://github.com/fizruk/http-api-data

Version on this page:0.1.1.1@rev:1
LTS Haskell 24.1:0.6.2
Stackage Nightly 2025-07-25:0.6.2
Latest on Hackage:0.6.2

See all snapshots http-api-data appears in

BSD-3-Clause licensed and maintained by Nickolay Kudasov
This version can be pinned in stack with:http-api-data-0.1.1.1@sha256:a645ae3d2a539a53d206005d36641ab1a21433b834598f08b23c2873c1264777,1747

Module documentation for 0.1.1.1

Depends on 4 packages(full list with versions):

http-api-data

Hackage package Build Status

This package defines typeclasses used for converting Haskell data types to and from HTTP API data.

Examples

Booleans:

>>> toUrlPiece True
"True"
>>> parseUrlPiece "False" :: Either Text Bool
Right False
>>> parseUrlPiece "something else" :: Either Text Bool
Left "could not parse: `something else'"

Numbers:

>>> toUrlPiece 45.2
"45.2"
>>> parseUrlPiece "452" :: Either Text Int
Right 452
>>> parseUrlPiece "256" :: Either Text Int8
Left "out of bounds: `256' (should be between -128 and 127)"

Strings:

>>> toHeader "hello"
"hello"
>>> parseHeader "world" :: Either Text String
Right "world"

Calendar day:

>>> toQueryParam (fromGregorian 2015 10 03)
"2015-10-03"
>>> toGregorian <$> parseQueryParam "2016-12-01"
Right (2016,12,1)

Contributing

Contributions and bug reports are welcome!

Changes

0.1.1

  • Add use-text-show flag to optionally use more efficient TextShow instances