[Haskell-beginners] small question

Bastian Erdnüß earthnut at web.de
Tue Oct 19 16:44:00 EDT 2010


On Oct 19, 2010, at 22:10, Isaac Dupree wrote:

> On 10/19/10 14:35, Bastian Erdnüß wrote:
>>   xor False = id
>>   xor True  = not
>>   infixr 2 xor
> 
> Also, exclusive-or on Bool can be written as /= (the first boolean is not equal to the second boolean), which makes sense to use because /= is a standard function.

Cool.  Never thought of it that way.  Then it turns out to be even more easy:

  instance OBSERVATIONS Drinkability WaterWell Volunteer where
    observe (Drinkability waterWell) volunteer =
      volunteer { vReport = drinkability } where
        drinkability = drinkableIf $ claimedAppereance == honesty volunteer
        claimedAppereance =
          odorQuale     (perceive (Odor     waterWell) volunteer) &&
          clarityQuale  (perceive (Clarity  waterWell) volunteer) &&
          fullnessQuale (perceive (Fullness waterWell) volunteer)
        drinkableIf True  = "drinkable"
        drinkableIf False = "undrinkable"

Regards,
Bastian



More information about the Beginners mailing list