caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Simple(?) subtyping problem...
Date: Tue, 24 Oct 2006 22:53:20 +0100	[thread overview]
Message-ID: <200610242253.20095.jon@ffconsultancy.com> (raw)
In-Reply-To: <9d3ec8300610241345k1600fd9dqe3a3bba5c4bd9def@mail.gmail.com>

On Tuesday 24 October 2006 21:45, Till Varoquaux wrote:
> I'm currently trying to split functions matching against given variant
> type and I'm running across this pb:
>
> let a= function
>
>  | `A -> ()
>  | `B -> ()
>
> doesn't split into
>
> let c=function
>
>  | `B -> ()
>
> let b =function
>
>  | `A -> ()
>  |  x -> c x
>
> since it messes up the type rules. I really want to avoid having to
> write down precise type informations (The point here is to have an
> extensible system)...

How about:

# type c = [`B];;
type c = [ `B ]
# let c = function
    | #c -> ();;
val c : [< c ] -> unit = <fun>
# let b k = function
    | `A -> ()
    | #c as x -> c x
    | x -> k x;; 
val b : (([> `A | `B ] as 'a) -> unit) -> 'a -> unit = <fun>

> I am sure this question has been asked loads of times (but I couldn't
> find the right thread in the archives) and I apologize for asking it
> yet again.

I don't think it comes up very often.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists


  reply	other threads:[~2006-10-24 21:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-24 20:45 Till Varoquaux
2006-10-24 21:53 ` Jon Harrop [this message]
2006-10-24 22:46 ` [Caml-list] " Jacques Garrigue
2006-10-25  6:03   ` Till Varoquaux
2006-10-25  7:16     ` 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=200610242253.20095.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.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).