Discussion:
subtyping of -> and tuples
Kamil Dworakowski
2007-06-15 09:37:31 UTC
Permalink
Why there is no subtyping for -> and tuples?

code from MType.Require:

| (Fun (f1, t1), Fun (f2, t2)) =>
// f2.Require (f1) && t1.Require (t2)
f1.Unify (f2) && t1.Unify (t2)

| (Tuple (l1), Tuple (l2))
when List.Length (l1) == List.Length (l2) =>
List.ForAll2 (l1, l2, fun (x : TyVar, y : TyVar) { x.Unify (y) })


-- Kamil Dworakowski
Michal Moskal
2007-06-15 09:47:28 UTC
Permalink
Post by Kamil Dworakowski
Why there is no subtyping for -> and tuples?
| (Fun (f1, t1), Fun (f2, t2)) =>
// f2.Require (f1) && t1.Require (t2)
f1.Unify (f2) && t1.Unify (t2)
| (Tuple (l1), Tuple (l2))
when List.Length (l1) == List.Length (l2) =>
List.ForAll2 (l1, l2, fun (x : TyVar, y : TyVar) { x.Unify (y) })
Because there is no runtime subtyping in the underlaying .NET VM.
We've tried to provide implicit conversions, but it doesn't always
work.
--
Micha³
Loading...