[mercury-users] name clashes in typeclasses

David Glen JEFFERY dgj at hydra.cs.mu.oz.au
Thu Oct 7 01:23:39 AEST 1999


On 06-Oct-1999, Michael Day <mikeday at corplink.com.au> wrote:
> is it possible for two type classes in the same module to contain a
> predicate with the same name? 

Not at the moment, no. The semantic analysis passes of the compiler treat a 
type class method just like any other predicate. For example, given:

:- typeclass c(T) where [ pred m(int::in, T::out) is det].

the method `m' is treated like:

:- pred m(int, T) <= c(T).
:- mode m(in, out) is det.

Having more than one method with the same name and arity in the same
module is the same as having more than one *pred* with the same name and
arity in the same module, which we don't allow.

> If not, would it be possible for these
> predicates to be qualified by type class name in some way? 

Allowing this would be a bit of work, but quite doable. I'm not sure that it
is entirely desirable, though; I suspect it would be Yet Another Complication
for relatively little gain. Thoughts anyone?

( Anyhow, if we did allow qualification of a method name by a type class
name, what operator would we use? ;-) )


dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student,                    | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.|     With sufficient formality
The University of Melbourne     |     The sheerist banality
Australia                       | Will be hailed by the critics: "Miraculous!"
                                |     -- Anon.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list