Haskell Library Demonstrating Dependent Types in eDSL

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

What is (2 + 5] + 200?
Please leave these three fields as-is: