Help making this "poly/generic" code compile

There is no ad-hoc polymorphism in OCaml, only parametric polymorphism. Thus the function (=): 'a -> 'a -> bool is defined for all types'a (even if it does fail dynamically on some memory representation). Type constraints of the form 'a . ... reads for all types 'a. ... . A more natural example would be:

let rec len: 'a. 'a list -> int = function
| [ ] -> 0
| _ :: q -> 1 + len q