Parsec Library Questions

I'm currently trying to run through this tutorial on the Parsec Library http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#operator and I have a few basic questions that I'm hoping someone might be able to shed some light on. 1. I seem to be having some issues with importing Parsec modules for instance. "import Parsec" as outlined in the introduction causes errors as does a number of the imports used later on in the paper and a solution that I have found is to further specify "import Text.Parsec" is this due to some changes to importing since the paper was written (in 2001 I believe)? 2. Can anyone recommend if this is a good source to learn to use the Parsec Library or if there are any other recommended documents I would benefit from ? 3. I have also tried to run the files that I have created in hugs and ghc and while they work in ghc, hugs on the other hand complains about the import statements I making e.g. "import Text.Parsec.Expr" Thanks in advance for any help!! Seán

Hi Sean
On Tue, Jan 22, 2013 at 6:22 PM, Sean Cormican
I'm currently trying to run through this tutorial on the Parsec Library http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#operator and I have a few basic questions that I'm hoping someone might be able to shed some light on.
1. I seem to be having some issues with importing Parsec modules for instance. "import Parsec" as outlined in the introduction causes errors as does a number of the imports used later on in the paper and a solution that I have found is to further specify "import Text.Parsec" is this due to some changes to importing since the paper was written (in 2001 I believe)?
Initial version of Parsec was written using state monad and later it was written using monad transformar library so I guess this could be a reason. May be some one with more experience in parsec can explain it.
2. Can anyone recommend if this is a good source to learn to use the Parsec Library or if there are any other recommended documents I would benefit from ?
Here are couple of links and you can search more files on github. 1. http://www.vex.net/~trebla/haskell/parsec-generally.xhtml 2. http://dl.dropbox.com/u/7810909/docs/haskell-parsers/haskell-parsers/html/in... 3. http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing 4. https://github.com/jhartikainen/hs-language-php/blob/master/Tokenizer.hs 5. http://www.haskell.org/haskellwiki/Parsing_expressions_and_statements 6. http://www.haskell.org/haskellwiki/Parsing_a_simple_imperative_language 7. https://github.com/tomahawkins/verilog/blob/master/Language/Verilog/Parser.h...
3. I have also tried to run the files that I have created in hugs and ghc and while they work in ghc, hugs on the other hand complains about the import statements I making e.g. "import Text.Parsec.Expr"
Thanks in advance for any help!!
Mukesh
Seán
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Tue, Jan 22, 2013 at 7:52 AM, Sean Cormican
1. I seem to be having some issues with importing Parsec modules for instance. "import Parsec" as outlined in the introduction causes errors as does a number of the imports used later on in the paper and a solution that I have found is to further specify "import Text.Parsec" is this due to some changes to importing since the paper was written (in 2001 I believe)?
Flat Haskell98 modules are no longer used; they pollute the namespace. Additionally, the Parsec3 API was for a time not 100% backward compatible (and may still require type annotations sometimes) and at one point was significantly slower than Parsec2, so it was relocated in order to allow them to coexist in a somewhat comprehensible way.
3. I have also tried to run the files that I have created in hugs and ghc and while they work in ghc, hugs on the other hand complains about the import statements I making e.g. "import Text.Parsec.Expr"
hugs is no longer maintained; I doubt it can handle Parsec3 fully. If for some reason you must use Hugs, you might want to stick to Parsec2. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Tue, Jan 22, 2013 at 7:52 PM, Sean Cormican
2. Can anyone recommend if this is a good source to learn to use the Parsec Library or if there are any other recommended documents I would benefit from ?
I think Daan wrote a lucid if slightly bitrotted parsec tutorial (and not just parsec itself) that many library users can benefit from. In addition, it gives a good glimpse of the thinking behind the library design. If only more libraries on hackage were similarly documented. For a grasp of the evolution from the pre- to the post-monad picture, I'd also recommend the following sources cited in the tutorial. The Monad and MonadPlus instances act as familiar sugar over the otherwise more brittle code that results from working with the combinators directly. The sugar is translated away eventually, so it's still necessary to grasp the underlying higher-order functions. Graham Hutton. (1992) Higher-order functions for parsing. Journal of Functional Programming 2: 232-343. http://www.cs.nott.ac.uk/Department/Staff/gmh/parsing.ps. Graham Hutton and Erik Meijer. (1996) Monadic Parser Combinators. Technical report NOTTCS-TR-96-4. Department of Computer Science, University of Nottingham. http://www.cs.nott.ac.uk/Department/Staff/gmh/monparsing.ps. And also the chapter in Hutton's textbook. It's also useful to know that parser combinators vs parser generators (like yacc and happy) are good examples of shallow- vs deeply-embedded DSLs. Many of the relative advantages of each aren't specific to parsing but apply generally to the shallow vs deep divide. <---- Digressing further, let me just note that much of the knowledge of DSL design and implementation is folklore for which there's no good source of information. One could do worse than take parsing as a case study and go from there. -- Kim-Ee
participants (4)
-
Brandon Allbery
-
Kim-Ee Yeoh
-
mukesh tiwari
-
Sean Cormican