[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques Carette <carette@m...> |
| Subject: | Re: [Caml-list] Not a variant?? |
Jacques Garrigue wrote:
> The message is maybe not clear enough: for pattern-matching and
> inheritance, you need an "exact" variant type, i.e. a type whose lower
> and upper bounds are identical.
Indeed - I would suggest that the error include some clearer diagnostics
that indicate how the variant is 'inexact'.
> The standard workaround is to write:
>
> type c0 = [a | b]
> type 'a c = 'a constraint 'a = [< c0]
>
This got me further, thanks. But not far enough...
Here is a simple example of the problems I am now running into:
type 'a a = [`A of 'a ]
type 'a b = [`B of 'a ]
type d = [`D ]
type ('a,'b) e = ['b a | 'a b | d]
type ('a,'b) c = ('a,'b) e
constraint 'a = [< 'b a ]
constraint 'b = [< 'a b ]
type 'd cc = 'd
constraint 'd = [< ('a,'b) c]
let is_cc = function
| #cc -> true
| _ -> false
;;
(* complains that cc is not a variant type when trying to define is_cc *)
Jacques Carette