[mercury-users] determinism suprises

William Lee Irwin III wli at holomorphy.com
Sat Dec 9 22:08:02 AEDT 2000


On Sat, Dec 09, 2000 at 08:20:36PM +1100, Fergus Henderson wrote:
> In general, you should not declare modes for predicates in which they
> produce values for output arguments that are unconstrained, as is the
> case for all the modes of `add_parity' that have determinism `multi'.
> Instead, you should use the "constrain and then generate" paradigm.
> You should omit declarations for those modes, and instead use an
> explicit generator predicate, e.g. `gen_parity', to generate
> unconstrained values.
> 	:- pred gen_parity(parity).
> 	:- mode gen_parity(in) is det.
> 	:- mode gen_parity(out) is multi.
> 	gen_parity(even).
> 	gen_parity(odd).

This looks like Haskell's typeclass Enum. Your earlier suggestion
of a typeclass for this sounds like it could come in handy for other
places where this happens, too.

It looks like what I'm missing here is a bit of logic programming idiom.
I can go back and knock down a bunch of things with this one...

Thanks,
Bill
-- 
Mathematicians are like Frenchmen: whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different.
-- Goethe
--------------------------------------------------------------------------
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