Please log in to watch this conference skillscast.
Haskell is well established as a backend language for client-server applications, and at the same time, new functional languages are gaining popularity on the frontend side. Implementing a client-server communication API, it is very important that there is a seamless conversion between the data types at both ends of the communication channel. Haskell provides an elegant way of deriving JSON serialisers and deserialisers, but unfortunately, this is not true for the majority of languages, so we still end up having to write these instance manually, which is a lot of effort, involves writing boilerplate code, and is generally error-prone.
GHC Generics provides us with the necessary metadata to be able to generate data types in other languages based on our Haskell implementation, and even generate code to serialise and deserialise these structures using either JSON, or any other arbitrary serialisation technique, such as CBOR.
This way, despite our frontend and backend applications beingwritten in different languages, we can have static guarantees about the correctness of the marshalling mechanisms.
In this lightning talk, you will learn some motivation for generating such types and the corresponding serialisers, and a concrete implementation for the frontend language Elm.
There are also some interesting special considerations that are specific to Elm, for example, involving extensible records.
You will enjoy this talk if you are a beginner and interested in Haskell's ability of proving properties statically, and leveraging these static properties to eliminate boilerplate code.
The Call for Papers is now open for Haskell eXchange 2017! Submit your talk for the chance to join a stellar line-up of experts on stage. Find out more.
YOU MAY ALSO LIKE:
- Lightbend's Fast Track to Akka with Java (in London on 16th - 18th August 2017)
- F# eXchange 2018 (in London on 5th - 6th April 2018)