Search code examples
haskellfunctional-programming

Functions that can be deduced by their type signature


I was introduced to this idea informally by this c++ talk Ben Deane “Using Types Effectively"

For example:

template<typename T, typename U>
T f(pair<T, U>);

can be deduced to be first.

  • What is the proper terminology for this?
  • Are there some resources to learn more?

Solution

  • David Young already answered this in the comments of my other question.

    Regarding functions with only one possible implementation: This is the result of something called "parametricity". Sometimes it is not only one implementation, but the collection of possible implementations is very restricted. This fact is expressed by a "free theorem." Every parametrically polymorphic function has an associated free theorem. Some resources: 1, 2, 3, 4