Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-09-21 (23:15)
From: Hezekiah M. Carty <hcarty@a...>
Subject: Re: [Caml-list] Measures
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!


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:

The underlying Length library code is based on a post by Richard
Jones' ( 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.


Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science