Version française
Home     About     Download     Resources     Contact us    
Browse thread
Fwd: "ocaml_beginners"::[] Trouble combining polymorphic classes and polymorphic methods
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Fwd: "ocaml_beginners"::[] Trouble combining polymorphic classes and polymorphic methods
On Wed, 2007-02-28 at 10:34 +0900, Jacques Garrigue wrote:

> and polymorphism. What some people do not like about structural types
> is that they do not "brand" types: you can define the same type
> elsewhere, possibly with a different intended meaning, and the
> compiler will not distinguish between the two. 

Of course you CAN brand types if you want to!

type 'a metres = Metres of 'a 
type 'a feet = Feet of 'a 

type int_metres = int metres
type int_feet = int feet

or perhaps 

type metres = { metre: int }
type feets  = { feet: int }

or some other trick with phantom types I'm sure someone will
point out.

After all a nominal type is just a structural type with
a unique tag representing its unique name.

Look at in the converse: a structural type is just the
canonical representative of nominal types with the
same structure.

Or perhaps i'm confused .. :)

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net