Version française
Home     About     Download     Resources     Contact us    
Browse thread
What is an open type?
[ 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] What is an open type?
On Fri, 2004-11-26 at 05:19, Christophe TROESTLER wrote:
> On 26 Nov 2004, skaller <skaller@users.sourceforge.net> wrote:
> > 
> > An open type like [> `X ] isn't actually a type, you can't
> > name it like:
> > 
> > type xx = [> `X ]
> 
> It is polymorphic:
> 
> type 'a xx = 'a constraint 'a = [> `X];;

Wow! I didn't realise you could do that.
This solves a heap of problems for me. Thanks!

This looks (visualy) like

   'a constraint >= [ `X ]

i.e. a sneaky way of getting subtyping :)

Pity this doesn't work:

# type pm = 'b constraint 'b = [> ];;
A type variable is unbound in this type declaration

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net