From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id CC14ABC57 for ; Sat, 1 May 2010 22:01:28 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArUBAJYl3EtQW+UMmWdsb2JhbACDF41IjFIVAQEBAQEICwoHESKpd5AXgSaCfm4EhjI X-IronPort-AV: E=Sophos;i="4.52,311,1270418400"; d="scan'208";a="50181630" Received: from lo.gmane.org ([80.91.229.12]) by mail2-smtp-roc.national.inria.fr with ESMTP; 01 May 2010 22:01:28 +0200 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O8IsR-00019D-73 for caml-list@inria.fr; Sat, 01 May 2010 22:01:27 +0200 Received: from ks300734.kimsufi.com ([91.121.65.225]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 01 May 2010 22:01:27 +0200 Received: from sylvain by ks300734.kimsufi.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 01 May 2010 22:01:27 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr connect(): No such file or directory From: Sylvain Le Gall Subject: Re: Subtyping structurally-equivalent records, or something like it? Date: Sat, 1 May 2010 20:01:19 +0000 (UTC) Message-ID: References: <602616.65342.qm@web111501.mail.gq1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ks300734.kimsufi.com User-Agent: slrn/pre1.0.0-11 (Linux) X-Spam: no; 0.00; le-gall:01 subtyping:01 abbreviation:01 ocaml:01 node:01 velocity:98 wrote:01 precisely:01 suggestion:03 discusses:04 ang:04 types:05 problem:05 phantom:07 phantom:07 On 01-05-2010, Dario Teixeira wrote: > Hi, > >> type kinematic = { lin: Vec.t; ang: Vec.t } >> >> Which I've been using to represent a medley of physical attributes (force, > momentum, velocity, etc.). > > I second Stéphane's suggestion of using phantom types; moreover, > I recommend you read an article that discusses them to some detail > and covers their use for precisely this sort of problem: > http://camltastic.blogspot.com/2008/05/phantom-types.html > I really like the use of private type abbreviation for phantom type: http://ocaml.janestreet.com/?q=node/77 Regards, Sylvain Le Gall