This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

[Caml-list] Efficiency of 'a list
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2003-05-04 (12:30) From: Olivier Andrieu Subject: Re: [Caml-list] Two types of efficiency (Was Efficiency of 'a list)
``` John Max Skaller [Sunday 4 May 2003] :
> Similarly, subtyping of polymorphic variants is invariant
> in the arguments, when covariance is sound and more useful.
> This is a real pain for me, since it destroys the main use
> I hoped to obtain for polymorphic variants:
>
> type x = [`A | `B of x]
> type y = [`A | `B of y | `C]
>
> x *is* a subtype of y, but the type system
> disallows it, failing to recognise that every `B x
> of type x is also a `B y of y. Typically I have
> say a term for an expression and I want to eliminate
> some cases by say a term reduction, but I can't restrict
> the resultant type as desired because there's no way
> to 'narrow' the type recursion.

# type x = [`A | `B of x] ;;
type x = [ `A | `B of x]
# type y = [`A | `B of y | `C] ;;
type y = [ `A | `B of y | `C]
# fun a -> (a :x :> y) ;;
- : x -> y = <fun>

Doesn't that mean that x is a subtype of y ?

--
Olivier

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

```