[mercury-users] Existential type constraints

Mark Brown mark at cs.mu.OZ.AU
Fri Jul 29 11:37:56 AEST 2005


On 29-Jul-2005, Peter Hawkins <peter at hawkins.emu.id.au> wrote:
> Hi...
> 
> Why is this legal mercury?
> 
> :- typeclass c(T).
> :- pred foo(T::in) => (c(T)).
> 
> Shouldn't it be illegal to add an existential type class constraint on 
> an non-existentially typed variable?

It isn't legal.  With a recent compiler you should get an error message along
the lines of: "In declaration of predicate `t.foo/1': type variable T is
existentially constrained, but is universally quantified."

Whether it _should_ be illegal or not is another question.  But we don't
currently support this kind of thing and we aren't likely to in the
foreseeable future.

> 
> (I just spent an enjoyable 15 minutes tracking down a missing 'some [T]' 
> on a predicate declaration, and I wasn't helped by a misleading error 
> message).

What version of the compiler are you using, and what was the misleading
error message?

Cheers,
Mark.

--------------------------------------------------------------------------
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