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. questions about "Write yourself a Scheme in 48 hours"
(Michael Litchard)
2. Re: questions about "Write yourself a Scheme in 48 hours"
(Krzysztof Skrz?tnicki)
3. Re: questions about "Write yourself a Scheme in 48 hours"
(Mike Meyer)
----------------------------------------------------------------------
Message: 1
Date: Fri, 8 Apr 2011 18:45:26 -0700
From: Michael Litchard <[email protected]>
Subject: [Haskell-beginners] questions about "Write yourself a Scheme
in 48 hours"
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
I'm working through "Write yourself a Scheme in 48 hours". I'm on the
parsing section
http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing
and I have a question about the following function
parseNumber :: Parser LispVal
parseNumber = liftM (Number . read) $ many1 digit
digit looks like a variable, but I don't see it mentioned anywhere.
Where is the input coming from?
Is this an example of partial application?
------------------------------
Message: 2
Date: Sat, 9 Apr 2011 04:00:34 +0200
From: Krzysztof Skrz?tnicki <[email protected]>
Subject: Re: [Haskell-beginners] questions about "Write yourself a
Scheme in 48 hours"
To: Michael Litchard <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
digit is predefined parser. The implementation is similar to
digit = oneOf "0123456789"
Be sure to read carefully though. At the beginning of Chapter 2 (Parsing) it
reads:
*Parsec provides a number of pre-built parsers: for example, letter and
digit are library functions.*
Also, I recommend downloading the ebook as PDF. It is easier to read that
way.
Best regards,
Krzysztof Skrz?tnicki
On Sat, Apr 9, 2011 at 03:45, Michael Litchard <[email protected]> wrote:
> I'm working through "Write yourself a Scheme in 48 hours". I'm on the
> parsing section
> http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing
>
> and I have a question about the following function
>
> parseNumber :: Parser LispVal
> parseNumber = liftM (Number . read) $ many1 digit
>
> digit looks like a variable, but I don't see it mentioned anywhere.
> Where is the input coming from?
> Is this an example of partial application?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110409/68bb5d11/attachment-0001.htm>
------------------------------
Message: 3
Date: Fri, 8 Apr 2011 22:35:26 -0400
From: Mike Meyer <[email protected]>
Subject: Re: [Haskell-beginners] questions about "Write yourself a
Scheme in 48 hours"
To: Michael Litchard <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
On Fri, 8 Apr 2011 18:45:26 -0700
Michael Litchard <[email protected]> wrote:
Wow. I get to answer a question. Or at least try...
> I'm working through "Write yourself a Scheme in 48 hours". I'm on the
> parsing section
> http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing
>
> and I have a question about the following function
>
> parseNumber :: Parser LispVal
> parseNumber = liftM (Number . read) $ many1 digit
>
> digit looks like a variable, but I don't see it mentioned anywhere.
It's from the Parsec library. It parses a single digit from the input.
> Where is the input coming from?
To be determined. parseNumber is a Parser monad that returns a LispVal
(at least, that's what the type says it is). You run it with the parse
function, which is where you specify the input to be parsed.
> Is this an example of partial application?
No. All the functions have all their arguments supplied. Demonstrating
that is left as an exercise.
I started with WYAS, but wanting to actually do the exercises meant
that starting with Parsec (what looks like a particularly difficult to
understand example of one of the more difficult parts of haskell) was
a bad idea. I switched to Real World Haskell
(http://book.realworldhaskell.org/read/), which covers just enough
monads to let you do some IO before getting into the rest of the
language. It also covers monads in general before getting into the
Parsec library. Not that there's anything wrong WYAS (and I plan to
get back to it), but RWH fit my needs better. You might give it a
look.
<mike
--
Mike Meyer <[email protected]> http://www.mired.org/consulting.html
Independent Software developer/SCM consultant, email for more information.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 34, Issue 17
*****************************************