
With the recent discussions on the libraries mailing list about the API of Bryan O'Sullivan's text library, and the fact that I'm looking at using it soon for the first time, are there any recommended best practices or tips & tricks people have come up with? For starters, I'm considering writing a polyparse [1] instance for Text. However, even with the current Bytestring instances for polyparse there seems to be an emphasis on character-based parsing. Is that the correct way of doing things? For example, what would be the best way to try to parse a text value when you don't care about case? At the moment, with my String-based parser, I'm doing repeated comparisons on Char values [2,3]. [1]: http://hackage.haskell.org/package/polyparse [2]: http://hackage.haskell.org/packages/archive/graphviz/2999.10.0.1/doc/html/sr... [3]: http://hackage.haskell.org/packages/archive/graphviz/2999.10.0.1/doc/html/sr... -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

For starters, I'm considering writing a polyparse [1] instance for Text. However, even with the current Bytestring instances for polyparse there seems to be an emphasis on character-based parsing. Polyparse is not very character-oriented at all; I tend to write a separate lexer, and then write the parsers over an application-specific token-stream. But ByteStrings are certainly character-oriented, and since many people like to mix lexing with parsing, I included an instance for BS. I imagine if someone wants to lex directly from a Text rather than a String or a BS, then that process is likely to be very character-oriented as well. Having said that, on those occasions when I do parse direct from a String-like input, almost all of the parsers use a "word" parser (i.e. multi-character, space-separated) as if it were a primitive. Such a word parser would almost certainly make heavy use of (break isSpace), unless there is a better alternative in Text? Is that the correct way of doing things? For example, what would be the best way to try to parse a text value when you don't care about case? When case is irrelevant, I tend to (map toUpper) over both the input stream, and any textual arguments to individual parsers. Regards, Malcolm

On 8 November 2010 21:28, malcolm.wallace
When case is irrelevant, I tend to (map toUpper) over both the input stream, and any textual arguments to individual parsers.
That won't quite work in my case: I need to keep arguments in the provided case, but the actual attributes, keywords, etc. are caseless. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com
participants (2)
-
Ivan Lazar Miljenovic
-
malcolm.wallace