[mercury-users] Type inheritance?

Lee Naish lee at cs.mu.oz.au
Wed Sep 24 11:10:37 AEST 1997


In message <199709231225.WAA09248 at mundook.cs.mu.OZ.AU>Fergus wrote:
>Type classes would however allow us to refine the mode system slightly
>to avoid the drawback mentioned above regarding mixing mode-based subtypes
>with polymorphic predicates.  The reason that the compiler needs to
>make conservative assumptions about mode-based subtypes is the existence of
>std_util__construct (which is used to implemented io__read, etc.).
>With type classes, we could in the usual case make more precise assumptions,
>and only use the more conservative assumptions in the case when the
>polymorphic predicate's argument type was declared to be a member of the
>`constructable' type-class.

If I understand this correctly, a possibly better approach would be to
restrict the types of predicates which are not "really" polymorphic.
Something like:

<polymorphic declaration> <= <type class for "nice" types>

"Real" polymorphic predicates like append (in fact, everything but some
very low level predicates) wouldn't need this extra condition.

The advantages would be that the "special case" would be related to the
predicates rather than the types of their arguments and you can tell much
more about a predicate by looking at its type/mode (I believe the fact
that polymorphism is "broken" in current version of Mercury is a
significant flaw).

Perhaps Fergus could elaborate?

	lee



More information about the users mailing list