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=1.2 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id C717DBC0B for ; Tue, 16 Jan 2007 22:05:50 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0GL5oBA006942 for ; Tue, 16 Jan 2007 22:05:50 +0100 Received: by ug-out-1314.google.com with SMTP id q2so1950544uge for ; Tue, 16 Jan 2007 13:05:50 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=mQml2GNclRugA3NdrGgXVeN7idP+gjiIeopU3tY9nsTTa3nIawyqrhFAp/9HR6e/WGYKHkpdoLbnfF3ecVm6S9PzNcmxGybn2IMqXyYZEMusLupNpLF5WDkLLixhs7Fcdznqsi7gPdtXZL/9/76vHnMZ6cPINa29ki/F5bHAnRU= Received: by 10.82.179.9 with SMTP id b9mr1351539buf.1168981549666; Tue, 16 Jan 2007 13:05:49 -0800 (PST) Received: by 10.82.175.13 with HTTP; Tue, 16 Jan 2007 13:05:49 -0800 (PST) Message-ID: Date: Tue, 16 Jan 2007 22:05:49 +0100 From: Tom To: "Seth J. Fogarty" Subject: Re: [Caml-list] Polymorphic Variants Cc: caml-list In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_37250_23029021.1168981549576" References: X-j-chkmail-Score: MSGID : 45AD3E2E.001 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 45AD3E2E.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; variants:01 variants:01 subtyping:01 subtyping:01 polymorphic:01 polymorphic:01 wrote:01 wrote:01 caml-list:01 functions:01 functions:01 int:01 int:01 data:02 data:02 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_37250_23029021.1168981549576 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 16/01/07, Seth J. Fogarty wrote: > > > 2) When I have different overlapping kinds of data, with a common root > and common parent, and functions that are only defined on certain > branches of the 'type tree.' This would be the hardest to replicate. > Could this be replicated by either using overloaded non-polymorphic variants, meaning that say Int of int can be shared by many types (almost like polymorphic variants, just that it is declared, and thus (at least I believe so) more typesafe) using records with overloaded fields and subtyping, so that you could have: type top = {common of string} type one_level_deep = {top | my_only of int} type independent = {my_only of string} so this would be possible: let to_str x -> x.common to_str {common = "first"}; to_str {common = "second"; my_only = 0} ? - Tom ------=_Part_37250_23029021.1168981549576 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline

On 16/01/07, Seth J. Fogarty <sfogarty@gmail.com> wrote:

2) When I have different overlapping kinds of data, with a common root
and common parent, and functions that are only defined on certain
branches of the 'type tree.' This would be the hardest to replicate.

Could this be replicated by either
using overloaded non-polymorphic variants, meaning that say Int of int can be shared by many types (almost like polymorphic variants, just that it is declared, and thus (at least I believe so) more typesafe)

using records with overloaded fields and subtyping, so that you could have:
type top = {common of string}
type one_level_deep = {top | my_only of int}

type independent = {my_only of string}
so this would be possible:
let to_str x -> x.common

to_str {common = "first"}; to_str {common = "second"; my_only = 0}
?

- Tom

------=_Part_37250_23029021.1168981549576--