Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Patrick M Doane <patrick@watson.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Polymorphic variant abbreviations
Date: Tue, 18 Sep 2001 20:05:46 -0400 (EDT)	[thread overview]
Message-ID: <Pine.BSF.3.96.1010918195012.58189B-100000@fledge.watson.org> (raw)
In-Reply-To: <Pine.BSF.3.96.1010918174443.58189A-100000@fledge.watson.org>

The last 2 questions were about possible minor improvements with using
abbreviations. Now I'm stumped - can anyone bail me out?

(* Some type definitions and abbreviations *)
type t = ([ `A of 'a list | `B | `C ]) as 'a 
type b = [ `B ]
type c = [ `C ]

(* A rename for one of the abbreviations *)
type b2 = b

(* Use of abbreviation and rename work okay *)
let f1 (#b as x1) (#b as x2) = `A [x1;x2]
let f2 (#b2 as x1) (#b2 as x2) = `A [x1;x2] 

(* Only direct abbreviation works with list constructor *)
let g1 ~(xs : #b list) =
  `A xs

(*
   this doesn't compile - says unbound class b2

let g2 ~(xs : #b2 list) =
  `A xs
*)

(* The first works as I would expect, the second gives a very unexpected
type. There seems to be some kind of unexpected unification going on
between terms. *)

let h1 (#b as x1) (#c as x2) = `A [x1; x2]
let h2 (x1 : #b) (x2 : #c) = `A [x1; x2]


Any ideas?

Thanks,
Patrick


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2001-09-19  0:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-18 22:48 Patrick M Doane
2001-09-19  0:05 ` Patrick M Doane [this message]
2001-09-19  8:37   ` Laurent Vibert
2001-09-19  8:56   ` Remi VANICAT
2001-09-19  8:01 ` Laurent Vibert
2001-09-19 16:35   ` Patrick M Doane
2001-09-19 12:45 ` Jacques Garrigue
2001-09-19 16:58   ` Patrick M Doane

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=Pine.BSF.3.96.1010918195012.58189B-100000@fledge.watson.org \
    --to=patrick@watson.org \
    --cc=caml-list@inria.fr \
    /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