Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  small question (Stephen Tetley)
   2.  Re: Defining custom parser using Parsec (Heinrich Apfelmus)
   3. Re:  small question (Mohamed)


----------------------------------------------------------------------

Message: 1
Date: Tue, 19 Oct 2010 15:20:46 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] small question
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

honesty is a field label, so effectively it creates a function

honesty :: Volunteer -> Bool

This should fix it:

if (honesty volunteer) then "drinkable" else "undrinkable"


------------------------------

Message: 2
Date: Tue, 19 Oct 2010 16:53:21 +0200
From: Heinrich Apfelmus <[email protected]>
Subject: [Haskell-beginners] Re: Defining custom parser using Parsec
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed

Brent Yorgey wrote:
> On Mon, Oct 18, 2010 at 04:58:42PM -0500, Jimmy Wylie wrote:
>> I do have one question though.  Do you always have to define your own
>> Applicative instance for GenParser when trying to use the Applicative
>> form? I noticed that both you and also RWH defined your own when
>> explaining this form of Parsec.  Is there no standard
>> Parsec.Applicative in the library.
> 
> I believe Parsec exports an Applicative instance in version 3.0 and
> later, but previous versions of Parsec did not include it.  After all,
> the first few versions of Parsec were written before Applicative was
> invented. =)

That's why have switched to Parsimony[1]. It's a simplified version of 
Parsec with a proper applicative instance.

   [1]: http://hackage.haskell.org/package/parsimony


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



------------------------------

Message: 3
Date: Tue, 19 Oct 2010 08:35:10 -0700 (PDT)
From: Mohamed <[email protected]>
Subject: Re: [Haskell-beginners] small question
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Stephan and Daniel,

Thank you both very much. It worked!

cheers,
M




________________________________
From: Daniel Fischer <[email protected]>
To: Mohamed <[email protected]>
Sent: Tue, October 19, 2010 4:36:37 PM
Subject: Re: [Haskell-beginners] small question

Hi,

On Tuesday 19 October 2010 16:13:05 you wrote:
> Hello folks,
>
> just a quickie here and would appreciate any help...

Stephen already told you that it should be

if (honesty volunteer) ...

, so

>
> 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")}

Don't use 'if condition == True'.
For Bool values, (== True) is the identity function, so

'condition == True' is exactly the same as 'condition'.

Cheers,
Daniel



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

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 28, Issue 31
*****************************************

Reply via email to