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 AF007BB84 for ; Mon, 22 Sep 2008 01:15:52 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiUBAMpy1kjRVciok2dsb2JhbACSYD4BAQEBCQkKCREDmx2Eaj6BZg X-IronPort-AV: E=Sophos;i="4.32,443,1217800800"; d="scan'208";a="17575425" Received: from wf-out-1314.google.com ([209.85.200.168]) by mail1-smtp-roc.national.inria.fr with ESMTP; 22 Sep 2008 01:15:52 +0200 Received: by wf-out-1314.google.com with SMTP id 24so1421112wfg.15 for ; Sun, 21 Sep 2008 16:15:51 -0700 (PDT) Received: by 10.142.174.8 with SMTP id w8mr1113874wfe.4.1222038951023; Sun, 21 Sep 2008 16:15:51 -0700 (PDT) Received: by 10.142.192.6 with HTTP; Sun, 21 Sep 2008 16:15:50 -0700 (PDT) Message-ID: <3a360f590809211615n2f3b0b23qff76dac9d8eb5074@mail.gmail.com> Date: Sun, 21 Sep 2008 19:15:50 -0400 From: "Hezekiah M. Carty" Sender: hcarty@mulethief.com To: "Jon Harrop" Subject: Re: [Caml-list] Measures Cc: caml-list In-Reply-To: <200809220030.31468.jon@ffconsultancy.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200809220030.31468.jon@ffconsultancy.com> X-Google-Sender-Auth: 86469ec3881a918c X-Spam: no; 0.00; statically:01 ocaml:01 delimited:01 overloading:01 viewcvs:01 delimited:01 overloading:01 compile-time:01 wrote:01 syntactic:01 typing:01 caml-list:01 arithmetic:01 constraints:03 seems:03 On Sun, Sep 21, 2008 at 7:30 PM, Jon Harrop wrote: > > This latest post about statically typing constraints beyond mere > floating-point values reminds me that the F# programming language just got > another new feature called "measures" that lets you add phantom types > representing units of measure and even handles arithmetic over them for you. > > I have not used measures yet myself but I was just wondering if the OCaml > world had already seen anything like this? > > I had been under the impression that this could not be made to work but, > obviously, I was wrong! Jon, The OSP Delimited Overloading project has an example which does a very simple version of something similar to F# measures. The relevant example files can be viewed here: https://forge.ocamlcore.org/plugins/scmsvn/viewcvs.php/trunk/examples/length/?root=pa-do The underlying Length library code is based on a post by Richard Jones' (http://camltastic.blogspot.com/2008/05/phantom-types.html) and the syntactic sugar comes from the work done by the Delimited Overloading folks. It does not provide the very cool "x meters per second times y seconds gives z meters" that the F# feature seems to provide, but it does provide a start - meters + feet will throw a compile-time error, for example. Hez -- Hezekiah M. Carty Graduate Research Assistant University of Maryland Department of Atmospheric and Oceanic Science