Git Product home page Git Product logo

servant-dhall's Introduction

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 

servant-dhall's People

Contributors

phadej avatar ryantm avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.