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: Ignoring the result of a monadic computation (Isaac Dupree)
2. Re: Parsing an integer (Lyndon Maydwell)
3. Re: Parsing an integer (Stephen Tetley)
----------------------------------------------------------------------
Message: 1
Date: Sun, 21 Nov 2010 13:48:11 -0500
From: Isaac Dupree <[email protected]>
Subject: Re: [Haskell-beginners] Ignoring the result of a monadic
computation
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 11/19/10 10:21, Brent Yorgey wrote:
> On Fri, Nov 19, 2010 at 07:56:02AM +0100, Tim Baumgartner wrote:
>> using
>> ignore :: Monad m => m a -> b -> m b
>> ignore m a = m>> return a
>>
>> I'm satisfied with this solution but searching hoogle I didn't find
>> a standard function for my ignore. Am I missing something?
>
> Nope, there isn't such a function, but I like it. It reminds me of
> (*>) and (<*) from Control.Applicative.
In fact, it is equal to: flip (<$)
with <$ from Control.Applicative
and it only needs a Functor constraint, not Monad or Applicative.
http://haskell.org/ghc/docs/6.12.1/html/libraries/base/Control-Applicative.html
As y'all found out though, in this case an actual Applicative function
looked like a cleaner way to write the parser.
-Isaac
------------------------------
Message: 2
Date: Mon, 22 Nov 2010 10:59:05 +0800
From: Lyndon Maydwell <[email protected]>
Subject: Re: [Haskell-beginners] Parsing an integer
To: Tim Baumgartner <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
I've found that the token library imposes conventions on whitespace
that make it difficult to use in many cases.
On Sun, Nov 21, 2010 at 11:19 PM, Tim Baumgartner
<[email protected]> wrote:
> Hi Stephen,
>
> yes, it's Parsec, but I write this parser only for learning the
> language, so I don't care if I rewrite existing code. But thanks for
> the advice regarding performance. Patrick's answer was perfect for me
> and I will get used to
>
> <$> = fmap
>
> soon.
>
> Tim
>
> 2010/11/21 Stephen Tetley <[email protected]>:
>> Where is the Parser monad coming from?
>>
>> If its Parsec, a "seasoned Haskeller" would avoid read (which is
>> re-parsing already parsed data) and use the integer parser from
>> Parsec's Token parser module.[*]
>>
>> [*] The one caveat is that the number parsers in this module follow
>> Haskell's lexical rules - you might not always want this.
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 3
Date: Mon, 22 Nov 2010 08:12:38 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Parsing an integer
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 22 November 2010 02:59, Lyndon Maydwell <[email protected]> wrote:
> I've found that the token library imposes conventions on whitespace
> that make it difficult to use in many cases.
True - as it can't be made to differentiate between newline and other
whitespace it does make writing line oriented parsers difficult. I
tend to write my own cut down version of the token modules at that
point.
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 29, Issue 31
*****************************************