I try to write a reverse function for a polymorphic list as shown.
let rev =
let rec impl_rec acc = function
| [] -> acc
| x::xs -> impl_rec (x::acc) xs
in impl_rec []
The compiler infers a type of
'_weak list -> '_weak list
However, If I provide the parameter explicitly.
let rev xs =
let rec impl_rec acc = function
| [] -> acc
| x::xs -> impl_rec (x::acc) xs
in impl_rec [] xs
The following code is able to infer the polymorphic type
'a list -> 'a list
There is no ref type. How does the OCaml Compiler infer the first version to a weak type?