type 'a list = Cons of {elt : 'a; tail : 'a list} | Nil
function length (list : 'b) : int =
match list with
| Nil -> 0
| Cons(_, l') -> length(l') + 1
end
This results in the following error message:
File "tmp.ae", line 5, character 4-7:
5 | | Nil -> 0
^^^
Error The constructor Nil : ∀ 'a : Type . list('a) does not belong to type w1
Which might be surprising to users. To help clarify things, it would help if:
the polymorphic type w1 could instead by named 'b as it is in the source
if the messages explicits that w1 is a type variable that is quantified over in the definition of length
Consider the following problem:
This results in the following error message:
Which might be surprising to users. To help clarify things, it would help if:
w1
could instead by named'b
as it is in the sourcew1
is a type variable that is quantified over in the definition oflength