3 Matching Annotations
 Aug 2020

toraritte.github.io toraritte.github.io

Original post is here.
This explanation should be combined with 24 Days of GHC Extensions: Rank N Types (see related hypothes.is note).


ocharles.org.uk ocharles.org.uk

Commonly the above definition is called the identity function. But in fact we should think of it as a whole family of functions. We should really say that id is an identity function for all types a. In other words, for every type T you might come up with, there is an identity function called id, which is of type T > T. This is the typecheckerâ€™s view anyway, and by turning on the RankNTypes extension we can be explicit about that in our code: {# LANGUAGE RankNTypes #} id :: forall a. a > a id x = x
This is such a nice description of
forall
. It should be combined withforall
is the typelevel "lambda" (also saved it here). 
In other words you cannot choose the definition of a value based on its type (for now).
What does this mean?
