caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "David Allsopp" <dra-news@metastack.com>
To: <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Polymorphic variant difference...
Date: Mon, 14 May 2007 11:52:04 +0100	[thread overview]
Message-ID: <002c01c79615$e9750b30$6a7ba8c0@treble> (raw)
In-Reply-To: <20070514100005.459F6BC70@yquem.inria.fr>

> Given a polymorphic variant type t with a label `B how does one build
> the type corresponding to t without the label `B.

So that you could write something like:

type t = [ `A | `B | `C ]

let f x =
  match x with
    `B                     -> (* x has type t *)
  | #(t minus [ `B ]) as x -> (* x has type [ `A | `C ] *)

I end up having to write lots of tedious extra types to achieve that
normally... I'd find a subtraction syntax very handy too.

On a similar subject, am I the only person who finds I often need to take a
fixed polymorphic variant value and coerce it so that it can just accept
more constructors e.g. (seriously contrived example)...

type t = [ `A | `B | `C ]

let f (x : t) =
  match x with
    `A -> `D
  | _  -> (x : t :> [> t ])

Something more concise than (x : t :> [> t ]) would be nice: e.g. (x ::> t)
But perhaps that really is a job for camlp4!



David


       reply	other threads:[~2007-05-14 10:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070514100005.459F6BC70@yquem.inria.fr>
2007-05-14 10:52 ` David Allsopp [this message]
2007-05-15  4:40   ` Jacques Garrigue
2007-05-15  9:45     ` David Allsopp
2007-05-15 10:21       ` Frédéric van der Plancke
2007-05-14 10:52 ` [Caml-list] Compiling a library with findlib David Allsopp
2007-05-14 13:46   ` Sébastien Hinderer
     [not found] <20070515154127.94D62BC96@yquem.inria.fr>
2007-05-15 17:02 ` [Caml-list] Polymorphic variant difference David Allsopp

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='002c01c79615$e9750b30$6a7ba8c0@treble' \
    --to=dra-news@metastack.com \
    --cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).