Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: carette@mcmaster.ca
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Not a variant??
Date: Thu, 21 Aug 2008 14:10:26 +0900 (JST)	[thread overview]
Message-ID: <20080821.141026.119280602.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <48AC1AF6.6050701@mcmaster.ca>

From: Jacques Carette <carette@mcmaster.ca>
> 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 *)

Sure, you must use #c as pattern, not #cc.
Or are you thinking of another problem?

Jacques Garrigue


      reply	other threads:[~2008-08-21  7:49 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
2008-08-21  5:10     ` Jacques Garrigue [this message]

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=20080821.141026.119280602.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=carette@mcmaster.ca \
    /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