Skip to content

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

License

Notifications You must be signed in to change notification settings

yesodweb/http-api-data

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-api-data

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 convert: `something else'"

Numbers:

>>> toUrlPiece 45.2
"45.2"
>>> parseUrlPiece "452" :: Either Text Int
Right 452

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!

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haskell 100.0%