From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id D3859BC6A for ; Wed, 25 Oct 2006 00:48:28 +0200 (CEST) Received: from rabbit.math.nagoya-u.ac.jp (rabbit.math.nagoya-u.ac.jp [133.6.130.5]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k9OMmQcE022584 for ; Wed, 25 Oct 2006 00:48:27 +0200 Received: from localhost (millas [172.16.30.29]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id k9OMmDsR017896; Wed, 25 Oct 2006 07:48:13 +0900 (JST) Date: Wed, 25 Oct 2006 07:46:28 +0900 (JST) Message-Id: <20061025.074628.104028766.garrigue@math.nagoya-u.ac.jp> To: till.varoquaux@gmail.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Simple(?) subtyping problem... From: Jacques Garrigue In-Reply-To: <9d3ec8300610241345k1600fd9dqe3a3bba5c4bd9def@mail.gmail.com> References: <9d3ec8300610241345k1600fd9dqe3a3bba5c4bd9def@mail.gmail.com> X-Mailer: Mew version 4.0.69 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 453E983A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; subtyping:01 dispatching:01 messes:01 extensible:01 caml-list:01 functions:01 slight:01 explicitly:01 inherit:01 variant:02 caml:02 archives:02 garrigue:03 garrigue:03 jacques:03 Slight variation on Jon's answer: type c = [`B] let c = function | `B -> () let b = function | `A -> () | #c as x -> c x which has exactly the same type as your original b. The way dispatching is typed in caml, you have to indicate explicitly which cases you inherit from c. But it should no hinder extensibility. Jacques Garrigue From: "Till Varoquaux" > 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)... > > 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. > > Till