In your code lazy_list
is not a new type but just an alias for lazy_node lazy_t
. And the Ocaml type inferer only consider real types, not aliases. So it infers the real type and doesn't check if there is an alias for this type.
The alias is used for the argument because Node (x,zl)
implies that zl
has type 'a lazy_list
.
You can add type annotation to enforce the use of the alias:
let con x zl: 'a lazy_list = lazy (Node (x,zl))