[Haskell-beginners] Parsec lexeme parsers and whitespace/eol characters
Brent Yorgey
byorgey at seas.upenn.edu
Wed Mar 6 21:17:47 CET 2013
On Mon, Mar 04, 2013 at 10:13:37AM +0000, Sean Cormican wrote:
> Hi Brent,
>
> I have been trying to use Parsec because there is more documentation and
> tutorials on using it.
>
> I am extremely limited as a functional programmer and just as bad as an
> actual programmer. I am currently 18 days away from the due date for this
> project and I have made little or no progress due to my lack of ability,
> would src-exts be difficult to pick up and use?
haskell-src-exts works extremely well, and it's not too hard to find
your way around it using the Haddock documentation. Start here:
http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts.html
Use one of the functions listed on that page to parse the file, and
then click on the types to take you to pages explaining what you get
back. For example, if you use parseFile you can see that you get back
a (ParseResult Module). Clicking on ParseResult, you can see that a
(ParseResult Module) is either (ParseOk m) where m is a Module, or
ParseFailed containing an error message. So you can pattern-match to
find out which. Then clicking on Module, you can see all the stuff
contained in a value of type Module. Keep clicking on types to learn
what they are.
The biggest difficulty is that since this is a parser for *all of*
Haskell, there will be *lots* of stuff that you don't care about. But
it might still be easier than trying to write your own parser; I am
not sure.
-Brent
More information about the Beginners
mailing list