The Mercury Project
Re: [mercury-users] determinism suprises

Home

News

Information
  Overview
  Features
  Documentation
  Papers
  Developers
  Events
  Reports

Mailing Lists
  Developers
  Users
  Search

Download
  Current Release
  Snapshot
  Old Releases

Related
  Applications
  MCORBA
  Contributing Code

Contact

Search

Subject: Re: [mercury-users] determinism suprises
From: William Lee Irwin III (wli@holomorphy.com)
Date: Sat Dec 09 2000 - 22:08:02 EST


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@cs.mu.oz.au
administrative address: owner-mercury-users@cs.mu.oz.au
unsubscribe: Address: mercury-users-request@cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request@cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



This mail archive was generated by hypermail 2b25 on Sun Dec 31 2000 - 00:40:04 EST.