[m-dev.] Ye Olde Subtyping Proposal

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Nov 13 11:31:27 AEDT 2002

On 12-Nov-2002, Mark Brown <dougl at cs.mu.OZ.AU> wrote:
> > Note that although adding an implicit polymorphic mode is unsafe
> > in that case, it *would* be safe if the type class foo(T) was declared
> > as e.g.  `:- typeclass foo(T) where [ func foo(T) = int ].'.
> > In general, it would be possible to examine the structure of the type class
> > and determine from that whether it is safe to add implicit polymorphic
> > modes, but I think that would be getting too clever; it's better to have
> > a simple rule that makes it easy for programmers to determine whether
> > a procedure is polymorphically moded, without requiring them to look at
> > the type class declaration(s) for any associated type class constraints.
> Agreed.  Perhaps we could allow "promise_free" declarations, the meaning of
> which be that the free theorem for each method is valid?

If we did support such a declaration, I think it should be checked,
rather than a promise.  It should be easy enough to detect when a class
has a method that can return a type containing T without taking
as input any T.

However, I think that this would have the same problem as just inferring
such declarations automatically: when a programmer looks at a mode
declaration, they should be instantantly able to tell whether the
mode declaration is polymorphic or not, without having to go look
for promise_free declarations or at the type class declarations.

Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au

More information about the developers mailing list