Haskell Library Demonstrating Dependent Types in eDSL

Posted on July 21, 2018 by Marko Dimjašević

Haskell Servant’s logo

In Haskell, servant is a library for declaring web APIs. What is interesting about the library is that it utilises the power of Haskell’s type system, in particular the power of dependent types in computing a return type of a function.

The library has a whole eDSL for writing servers and obtaining client functions. In a very well written educational post, Alp Mestanogullari gradually explores the problem of constructing a link from its components and motivates type-level programming in servant and in Haskell in general. This allows for more precise expression of the intent behind the library and for far fewer bugs to creep into the library and target program using the library. Of course, the post demonstrates a simple usage of dependent types, but still a very useful and powerful one. In case you are interested to learn more about dependent types, I encourage you to also take a look at Idris, a pure functional language with Haskell-like syntax and full support for type-level programming, i.e. full support for dependent types.