An example of how to derive types. Many thanks to mrvn, from #ocaml on FreeNode!!! The following statement is taken from the "Polymorphism and type constraints" section of Chapter 2 of "Developing Applications With Objective Caml" Example statement from which to derive types: # let compose f g x = f(g x) ;; Step 1 - Assign a letter to each term in the expression on the left hand side. Use letters starting from 'a # let compose (f:'a)(g:'b)(x:'c) = f(g x) ;; This should yeild the following types: val compose: 'a->'b->'c->'d = 'd is the right hand side. Now you have to figure out what the types the terms on the left hand side really are, based on the types of the terms on the right hand side. Step 2 - Start with the expression on the right hand side, inside the parenthesis. What type of expression is it? f(g x) What type of expression is "g x" ? It is a function named "g", that takes "x" as an argument. Step 3 - Write out the term of Step 2, assigning it types starting with the next free letter after the letters in Step 1. (g:'e->'f) Step 4 - Determine the type of the second term within the parenthesis on the right hand side, based on the type determined in Step 3. f(g x) Since "x" is the argument to "g", what type does it have to have, based on the results of Step 3? (x:'e) Step 5 - Substitute the newly discovered types of "g" and "x" back in to the left hand side: # let compose (f:'a)(g:'e->'f)(x:'e) = f(g x) ;; Step 6 - Now move to the term outside the parenthesis on the right hand side. What type of expression is it? f(g x) What type of expression is "f()" ? It is a function named "f". Step 7 - Assign types to the term in Step 6, starting with the next free letter after the letters in Step 5. (f:'g->'h) Step 8 - Since 'g is the input to f, then 'g must be synonymous with the output of the expression that is an argument to f, namely the g function. Based on what we know in Step 5, substitute 'g with its synonym: 'g = 'f Step 9 - Since 'h is the result of f, then 'h must be synonymous with the right hand side. Based on the type of the right hand side in Step 1, substitute 'h with its synonym: 'h = 'd Step 10 - Substitute the newly discovered types for f back in to the left hand side: # let compose (f:'f->'d)(g:'e->'f)(x:'e) = f(g x) ;; Step 11 - Using letters starting from 'a and ascending, substitute the types in Step 10: # let compose (f:'a->'b)(g:'c->'a)(x:'c) = f(g x) ;; Step 12 - The types of the example statement have been successfully derived: val compose : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b =