From: Jacques Carette <carette@mcmaster.ca>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Not a variant??
Date: Wed, 20 Aug 2008 09:24:06 -0400 [thread overview]
Message-ID: <48AC1AF6.6050701@mcmaster.ca> (raw)
In-Reply-To: <20080820.122102.241911903.garrigue@math.nagoya-u.ac.jp>
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
next prev parent reply other threads:[~2008-08-20 13:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-19 22:53 Jacques Carette
2008-08-20 3:21 ` [Caml-list] " Jacques Garrigue
2008-08-20 13:24 ` Jacques Carette [this message]
2008-08-21 5:10 ` Jacques Garrigue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48AC1AF6.6050701@mcmaster.ca \
--to=carette@mcmaster.ca \
--cc=caml-list@inria.fr \
--cc=garrigue@math.nagoya-u.ac.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox