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 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 30C4EBC69 for ; Wed, 5 Dec 2007 03:19:56 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAACaZVUeFBoIFh2dsb2JhbACPUAIBCAop X-IronPort-AV: E=Sophos;i="4.23,251,1194217200"; d="scan'208";a="19988683" Received: from rabbit.math.nagoya-u.ac.jp ([133.6.130.5]) by mail4-smtp-sop.national.inria.fr with ESMTP; 05 Dec 2007 03:19:54 +0100 Received: from localhost (zebra-172 [172.16.254.8]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id lB52HI1Q003591; Wed, 5 Dec 2007 11:17:18 +0900 (JST) Date: Wed, 05 Dec 2007 11:17:18 +0900 (JST) Message-Id: <20071205.111718.2004158852.garrigue@math.nagoya-u.ac.jp> To: steph@glondu.net Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Union of polymorphic variants... From: Jacques GARRIGUE In-Reply-To: <4755651C.5010407@glondu.net> References: <47554A47.0@glondu.net> <20071204.225712.186423247.garrigue@math.nagoya-u.ac.jp> <4755651C.5010407@glondu.net> X-Mailer: Mew version 4.2 on Emacs 21.4 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; variants:01 bool:01 steph:98 polymorphic:01 char:01 caml-list:01 garrigue:03 garrigue:03 jacques:03 jacques:03 let:03 let:03 generally:04 nagoya-u:04 types:05 From: Stephane Glondu > However, one can do: > > let f = function > | `A (`B _) -> ... > | `A (`C _) -> .. > > Would it be difficult to extend the system so that #b and #c expand to > the constructions above? Nothing is "difficult". But not everything is well-defined... The question is where do we start, where do we stop. type a = [`S of a | `Z] should #a be (`S _ | `Z) or (`S (`S _ | `Z) | `Z) or ...? type b = [`A of [`B] option] should #b be (`A (None | Some `B)) ? Generally, when such questions start to pop up, it is better to forget about it. It could still be a good idea, but we need more examples to see that. Note that you can still build the types by hand type 'a t = [`A of 'a] type b = [`B of bool] type c = [`C of char] type a = [b|c] t let f = function `A #b as x -> fb x | `A #c as x -> fc x Jacques Garrigue