servant-dhall: Servant Dhall content-type

[ bsd3, dhall, library, servant, web ] [ Propose Tags ]

Servant Dhall bindings.

Provides MimeRender and MimeUnrender instances. So you can accept and return Dhall expressions.

Note: Reading (and evaluating) Dhall expressions from untrusted sources is a security risk.


[Skip to Readme]
Versions 0.1, 0.1.0.1
Dependencies base (>=4.9 && <4.12), base-compat (>=0.10.1 && <0.11), bytestring (>=0.10.4.0 && <0.11), dhall (>=1.15.1 && <1.18), http-media (>=0.7.1.2 && <0.8), megaparsec (>=6.5.0 && <6.6), prettyprinter (>=1.2.0.1 && <1.3), servant (>=0.13 && <0.16), text (>=1.2.3.0 && <1.3) [details]
License BSD-3-Clause
Copyright 2018 Servant Contributors
Author Servant Contributors
Maintainer haskell-servant-maintainers@googlegroups.com
Revised Revision 3 made by phadej at Tue Nov 13 22:15:23 UTC 2018
Category Web, Servant, Dhall
Home page http://haskell-servant.readthedocs.org/
Bug tracker http://github.com/haskell-servant/servant-dhall/issues
Source repo head: git clone http://github.com/haskell-servant/servant-dhall.git
Uploaded by phadej at Thu Jul 5 15:24:29 UTC 2018
Distributions LTSHaskell:0.1.0.1, NixOS:0.1.0.1
Downloads 165 total (18 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-07-05 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for servant-dhall-0.1.0.1

[back to package description]

servant-dhall - Servant Dhall bindings

servant

Note: accepting dhall expressions from untrusted sources is a security risk.

Example

Run example

cabal new-run example run

Get

% curl 'localhost:8000/get'
[ +1, +2, +3, +4, +5, +6, +7, +8, +9, +10 ] : List Integer

Post

% curl -D - -X POST -H 'Content-Type: application/x-dhall' --data-raw '[+10,+20]' 'localhost:8000/post'
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Wed, 13 Jun 2018 10:41:07 GMT
Server: Warp/3.2.22
Content-Type: application/x-dhall

[ +11, +21 ] : List Integer

Error case: Unexpected type

% curl -D - -X POST -H 'Content-Type: application/x-dhall' --data-raw '[10]' 'localhost:8000/post'
curl: (7) Failed to connect to localhost port 8000: Connection refused
[FL973] ~/Documents/public-haskell/servant-dhall % curl -D - -X POST -H 'Content-Type: application/x-dhall' --data-raw '[10]' 'localhost:8000/post'
HTTP/1.1 400 Bad Request
Transfer-Encoding: chunked
Date: Wed, 13 Jun 2018 10:45:39 GMT
Server: Warp/3.2.22

Expected and actual types don't match : List Integer /= List Natural

Error case: Type error

% curl -D - -X POST -H 'Content-Type: application/x-dhall' --data-raw 'True && +1' 'localhost:8000/post'
HTTP/1.1 400 Bad Request
Transfer-Encoding: chunked
Date: Wed, 13 Jun 2018 10:51:52 GMT
Server: Warp/3.2.22

Type error: 
Error: ❰&&❱ only works on ❰Bool❱s

True && +1

(input):1:1

Error case: Imports

As deserialisation is done in pure context type-checking Dhall expressions with imports is not possible.

% curl -D - -X POST -H 'Content-Type: application/x-dhall' --data-raw 'http://example.com/dhall' 'localhost:8000/post'
HTTP/1.1 400 Bad Request
Transfer-Encoding: chunked
Date: Wed, 13 Jun 2018 10:53:52 GMT
Server: Warp/3.2.22

Import found: http://example.com/dhall