Browse thread
Re: [Caml-list] Subtyping structurally-equivalent records, or something like it?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Sylvain Le Gall <sylvain@l...> |
| Subject: | Re: Subtyping structurally-equivalent records, or something like it? |
On 01-05-2010, Dario Teixeira <darioteixeira@yahoo.com> 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