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.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 2F081BC69 for ; Wed, 17 Oct 2007 22:22:46 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAMgLFkfUGyodi2dsb2JhbACOTgIBCAQGCQgRB4En X-IronPort-AV: E=Sophos;i="4.21,290,1188770400"; d="scan'208";a="3125372" Received: from smtp3-g19.free.fr ([212.27.42.29]) by mail1-smtp-roc.national.inria.fr with ESMTP; 17 Oct 2007 22:22:46 +0200 Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id B1EC317B6CF; Wed, 17 Oct 2007 22:22:45 +0200 (CEST) Received: from [10.0.2.15] (rke75-3-82-229-183-156.fbx.proxad.net [82.229.183.156]) by smtp3-g19.free.fr (Postfix) with ESMTP id 570CB17B6CD; Wed, 17 Oct 2007 22:22:41 +0200 (CEST) Message-ID: <47166E74.40306@frisch.fr> Date: Wed, 17 Oct 2007 22:20:04 +0200 From: Alain Frisch User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Dario Teixeira Cc: Francisco Jos? Valverde Albacete , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Smells like duck-typing References: <706529.26231.qm@web54607.mail.re2.yahoo.com> In-Reply-To: <706529.26231.qm@web54607.mail.re2.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 cduce:01 ocamlduce:01 ocamlduce:01 fwiw:01 intersection:01 printf:01 printf:01 wrote:01 caml-list:01 int:01 int:01 alain:01 alain:01 Dario Teixeira wrote: >> To me your problems looks like a good candidate for XML-modelling and >> reusing all the tools for working in XML. The more so because XML was >> made... exactly for that! Why don't you give it at least a somewhat >> serious thought? > > Hi, > > You mean like CDuce and/or OCamlduce? I'm not particularly encouraging the use of OCamlduce here, but FWIW, a solution would look like: type title = {{ { title=Latin1 ..} }} type intro = {{ { intro=Latin1 ..} }} type blurb_t = {{ { id=Int .. } ++ title ++ intro }} type fresh_t = {{ { body=Latin1 .. } ++ title ++ intro }} type full_t = {{ blurb_t & fresh_t }} (* intersection type *) let print_metadata s = Printf.printf "%d: %s\n" {:s.id:} {:s.title:} If you're ok duplicating fields, the type definitions can be simplified: type blurb_t = {{ {id=Int title=Latin1 intro=Latin1 ..} }} type fresh_t = {{ {body=Latin1 title=Latin1 intro=Latin1 ..} }} type full_t = {{ {id=Int body=Latin1 title=Latin1 intro=Latin1 ..} }} -- Alain