[Haskell-beginners] small question

Mohamed bishrma at yahoo.com
Tue Oct 19 10:13:05 EDT 2010


Hello folks,

just a quickie here and would appreciate any help...

In this expression:



instance OBSERVATIONS Drinkability WaterWell Volunteer where
    observe (Drinkability waterWell) volunteer = volunteer {vReport = 
       if (odorQuale (perceive (Odor waterWell) volunteer) == True && 
clarityQuale (perceive (Clarity waterWell) volunteer) == True && fullnessQuale 
(perceive (Fullness waterWell) volunteer) == True) then (if (honesty) then 
"drinkable" else "undrinkable") else (if (honesty) then "undrinkable" else 
"drinkable")}

I get the following error:

  Couldn't match expected type `Bool'
           against inferred type `Volunteer -> Bool'
    In the expression: honesty
    In the expression: (if honesty then "drinkable" else "undrinkable")
    In the `vReport' field of a record

It is worth mention that Volunteer id defined as follows:

data Volunteer = Volunteer {vid:: Id, vloc:: Id, odorQuale:: Bool, 
clarityQuale:: Bool, fullnessQuale:: Bool, vQuale:: Bool, vReputation:: Float, 
honesty:: Bool, vReport:: Report} deriving Show 

Where Report is defined as:

type Report = String

I understand that the vReport field is not receiving a String as it should, but 
I have completely failed in knowing why! I just think the nesting of the if 
statements is correct but wonder why is it not working. What is the correct code 
to do what I intend from the abofe nonfunctioning if statements?

cheers,
m



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20101019/8995e7ad/attachment-0001.html


More information about the Beginners mailing list