[m-dev.] Foreign type compare and unification
Mark Brown
dougl at cs.mu.OZ.AU
Thu May 23 13:52:51 AEST 2002
On 21-May-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Mark Brown, Tuesday, 21 May 2002:
> > It would be nice to provide a generic method implementation, along the
> > lines of the function pprint__to_doc in the standard library. Perhaps
> > something like the following (note that, unlike ordinary instance
> > declarations, the parameter is a type variable):
> >
> > :- generic_instance printable(T) where [
> > (to_doc(X) = pprint__to_doc(X))
> > ].
> >
> > This would _not_ imply that all types are members of the typeclass. In
> > order to declare a type to be in the typeclass, we could use an ordinary
> > instance declaration, or we could use something like:
> >
> > :- derived_instance printable(foo).
> >
> > This would use the generic method, binding the hidden type parameter to
> > the type_info for foo.
>
> Surely this is the same as providing default method implementations?
No. The difference is that a default method implementation would be
used implicitly, whereas a derived instance of the above form must be
explicit.
Cheers,
Mark.
--------------------------------------------------------------------------
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