Dependently typed servers in Servant

Posted on December 2, 2015

Suppose we have a webserver that can perform different kinds of operations on different kinds of values. Perhaps it can reverse or capitalize strings, and increment or negate integers. Moreover, it can echo back any value. However, it does not make sense to try to reverse an integer or increment a string.

This is an example of a dependently typed server: the value that we are given as input determines the type of the rest of the server. If we get a string as input, we expect a string operation as the second argument and the response is also a string; if we get an integer as input, we expect an integer operation as the second argument and the response is also an integer.

Read more at well-typed.com