Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] [Q] explicit typing again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: [Caml-list] Polymorphic Variant Error message (CVS version)
# type t = [`A of t]
  let rec f (x:t) = match x with
  | `A y -> f y
  | `B y -> f y

Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Warning: this match case is unused.
type t = [ `A of t ]
val f : t -> 'a = <fun>
The first error message is a bit confusing.
There is indeed an extra tag `B in the match.

I think this kind of message only occurs where there
is a covariant type.

The confusion is: it says the pattern matching
is not exhaustive, but from the developers viewpoint
the opposite is true: the match is overconstrained,
rather than underconstrained. I guess the problem arises
becase the type of x is deduced from the match first,
before the annotation restricts it to type t.

Anyhow just curious exactly how this error arises.

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: