
16 Mar
2011
16 Mar
'11
9:38 a.m.
You want polymorphic variants. Check out O'Caml, or MLPolyR. Subtyping is not very compatible with first-class functions. If you have subtype-bounded polymorphism ("forall A a subtype of T, ..."), and your subtype relation says A -> B is a subtype of C ->D whenever A is a supertype of C and B is a subtype of D, then checking subtyping is undecidable. I might as well mention here that in any OO language with protected methods or members, a subclass is not a subtype in any behavioral sense - and terminal coalgebras have so little structure that just working in terms of the interface doesn't seem too useful. Brandon.