Abstract

We demonstrate how two Haskell libraries - Reflex-Dom and Servant - provide a powerful and complete web development framework which uses typechecking to guarantee many security and correctness properties on both the client and the server. With types as our guide, we can ensure that the data passed to our API is of the right shape, that we are forced to sanitize user input (eliminating most of the possibilities for SQL injection or XSS attacks), and that user input errors are guaranteed to be handled. We use Reflex, a Functional Reactive Programming engine, compiled with GHCJS (the Haskell-to-JavaScript transpiler) to lift user input into a safe representation. Types are used to enforce that all required data is requested from a user before the user can proceed to the next action in a workflow. Malformed user input is also cleanly separated at the type level for automatic reporting and recovery. Tutorial exercises will highlight Servant’s guarantees that a REST API is fully specified for all possible user inputs and return conditions. Tutorial attendees will gain an appreciation of how much work this up-front specification can save in development time. For example, Servant knows what all of your endpoints are, and serves error pages for everything else. Servant can also safely handle data conversions from the world of untyped Strings into the typesafe world of your API.

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.