[mercury-users] Typeclass problem (bug, misunderstanding, oth er?)

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Aug 4 19:35:53 AEST 2000


On 03-Aug-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> > From: Fergus Henderson [mailto:fjh at cs.mu.OZ.AU]
> > > solve(CFn, Solved, DummyNode) -->
> > >     ( if top_exhausted then
> > >         pop_stack(PoppedNodes),
> > >         push_agenda(PoppedNodes),
> > 
> > OK, you've passed the DummyNode in; but you haven't done 
> > anything with it.
> > So the type of PoppedNodes is still unconstrained.
> > You need to add some code to constrain the type of PoppedNodes
> > so that it uses the same node type as that used for DummyNode,
> > e.g. a call to
> > 
> > 	  { PoppedNodes `has_same_type_as` [DummyNode] }
> 
> Ahh.  This looks like a hole in type inference to me, now.
> From the typeclass definition and the typeclass constraint
> on solve/5 it can be deduced that PoppedNodes must have
> the same type as DummyNode:

No, it can't.

> :- typeclass csp(T, N) <= node(N) where [
> 	...
> 	pred pop_stack(list(N), T, T),
> 	...
> ].
> 
> :- pred solve(conflict_fn, bool, N, T, T) <= csp(T, N).
>
> So, N is related to T, the pop_stack/3 method returns a
> list of N, and we know that N is a polymorphically typed
> argument.

You're assuming here that the csp(T, N) instance
in the call to `solve' must be the same as that
in the call to `pop_stack'.  But there is no such
requirement.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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