let id x = x;;
val id : 'a -> 'a = <fun>
This is the identity function. It just returns whatever is passed to it.
id 5;;
- : int = 5
id "hello";;
- : string = "hello"
What does this 'a mean in it's signature?
It's a type variable. Type variables stand for an unknown type (the same way variables stand for an unknown value).
This is similar to Java's Generics: List<T>, or C++ template instantiation.
OCaml Syntax: a single quote followed by an identifier
Most often, it's 'a, and we normally call it "alpha" (We also say 'b = "beta" and 'c = "gamma")
This is a type of polymorphism.
We can write a function that works for many arguments, regardless of their type. This is called parametric polymorphism.