Version française
Home     About     Download     Resources     Contact us    
Browse thread
UsingPolymorphic Variants
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Using Polymorphic Variants
From: Christian Stork <cstork@ics.uci.edu>
> On Sun, Oct 02, 2005 at 10:43:42AM +0200, Jean-Marie Gaillourdet wrote:
> > Christian Stork schrieb:
> > > Basic Question:  
> 
> > >     Why aren't polymorphic variants coerced by default?
> 
> > I guess there is some undecidability involved.
> 
> My guess too, but I'd like to be sure. ;-)

Not really undecidable, but you would have to completely change the
way types are inferred, and accept type schemes with subtyping
constraints (cf. HM(X)).
Keeping all the subtyping explicit makes things simpler.
So there is no plan to change this.

> > >     ... f (x: type_of_x :> type_expected_by_f) ...
> > Isn't it possible to write something like that:
> >  (f: 'a) (x: type_of_x :> 'a)

The subtyping algorithm only looks at explicit types, so the sharing of
'a has no effect. In simple cases (with no recursive types), the
following will work:
  (c : type_of_x :> [> type_of_x ])

Jacques Garrigue