From: "Hezekiah M. Carty" <hcarty@atmos.umd.edu>
To: "Jon Harrop" <jonathandeanharrop@googlemail.com>
Cc: caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Measures
Date: Sun, 21 Sep 2008 19:15:50 -0400 [thread overview]
Message-ID: <3a360f590809211615n2f3b0b23qff76dac9d8eb5074@mail.gmail.com> (raw)
In-Reply-To: <200809220030.31468.jon@ffconsultancy.com>
On Sun, Sep 21, 2008 at 7:30 PM, Jon Harrop
<jonathandeanharrop@googlemail.com> 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
prev parent reply other threads:[~2008-09-21 23:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-21 23:30 Measures Jon Harrop
2008-09-21 23:15 ` Hezekiah M. Carty [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3a360f590809211615n2f3b0b23qff76dac9d8eb5074@mail.gmail.com \
--to=hcarty@atmos.umd.edu \
--cc=caml-list@yquem.inria.fr \
--cc=jonathandeanharrop@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox