[mercury-users] Subtyping for Mercury?
Tyson Richard DOWD
trd at students.cs.mu.oz.au
Tue Apr 15 16:37:14 AEST 1997
> > Anything which accepts a foo as a class should also accept a bar (but
> > not vice versa). Moreover, there should be a way of narrowing the type
> > of a bar object in order to access the hidden foo methods.
> This is achieved by using a `context' in a predicate --- ie. by placing
> constraints upon type variables eg:
> % T must be in the class `foo'. `foo' methods can be used upon things of
> % type T.
> :- pred baz(T::in, int::out) is det.
> % T must be in the class `bar'. `bar' methods can be used upon things of
> % type T, as can `foo' (because of the class hierarchy).
> :- pred kabam(T::in, int::out) is semidet.
Did I miss something? Where is the context? (I realize this is just
syntax, but the syntax appears to be missing).
Tyson Dowd #
# Sign on refrigerator:
trd at cs.mu.oz.au # Refrigerate after opening.
http://www.cs.mu.oz.au/~trd # - C. J. Owen.
More information about the users