Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* What is an open type?
@ 2004-11-25 15:57 skaller
  2004-11-25 18:19 ` [Caml-list] " Christophe TROESTLER
  0 siblings, 1 reply; 3+ messages in thread
From: skaller @ 2004-11-25 15:57 UTC (permalink / raw)
  To: caml-list

An open type like [> `X ] isn't actually a type, you can't
name it like:

type xx = [> `X ]

So what exactly is it?


-- 
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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] What is an open type?
  2004-11-25 15:57 What is an open type? skaller
@ 2004-11-25 18:19 ` Christophe TROESTLER
  2004-11-25 23:58   ` skaller
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe TROESTLER @ 2004-11-25 18:19 UTC (permalink / raw)
  To: skaller; +Cc: caml-list

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];;


Cheers,
ChriS


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] What is an open type?
  2004-11-25 18:19 ` [Caml-list] " Christophe TROESTLER
@ 2004-11-25 23:58   ` skaller
  0 siblings, 0 replies; 3+ messages in thread
From: skaller @ 2004-11-25 23:58 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: caml-list

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-25 23:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-25 15:57 What is an open type? skaller
2004-11-25 18:19 ` [Caml-list] " Christophe TROESTLER
2004-11-25 23:58   ` skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox