[Haskell-beginners] Defining custom parser using Parsec
Magnus Therning
magnus at therning.org
Tue Oct 19 02:43:47 EDT 2010
On 18/10/10 22:58, Jimmy Wylie wrote:
>
>> This sounds awfully lot like a premature optimisation, which as we all
>> know, is the root of evil :-)
>>
>> Why do you think that using Parsec will result in fewer transformations?
>> (It will most likely result in fewer transformations *that you see*, but
>> that doesn't mean much.)
>>
> I think you're right. I misunderstood the way the parsec library worked,
> and was trying to run before I could walk.
> However, it is a priority that I make this tool as fast as possible (as
> close to drive speed as I can). I wanted to take an "incremental" approach
> to optimization: writing small pieces, optimizing them, and then putting
> them together. I am also facing faculty skeptical that I can make things
> "fast" in haskell. (Currently, most DF applications are written in Python
> and C).
Well, I wouldn't say Python is *fast*, but as they say, it's often *fast
enough*. I don't see any reason for Haskell to do worse than that.
Profile stuff, both tools in C and Python that others have written, and your
own code. My experience is that many people, if not most, are guided not by
actual numbers but by some vague idea that low-level control somehow always
result in faster code.
>> http://therning.org/magnus/archives/289
>> http://therning.org/magnus/archives/290
>> http://therning.org/magnus/archives/295
>> http://therning.org/magnus/archives/296
>>
>> /M
>>
>> [1]: http://hackage.haskell.org/package/attoparsec-0.8.1.1
>>
> Thanks for the references. They're great blog posts, very easy to follow. I
> didn't realize how simple Parsec was to use, at least in the Monadic form.
> For some reason, I thought it was more complex.
Yeah, it's surprising isn't it? :-)
> I do have one question though. Do you always have to define your own
> Applicative instance for GenParser when trying to use the Applicative form?
> I noticed that both you and also RWH defined your own when explaining this
> form of Parsec. Is there no standard Parsec.Applicative in the library.
Those blog posts were written using Parsec 2.
As others have said, Parsec 3 is better equipped. Apparently both with
support for ByteString (which I didn't know) and an implementation for
Applicative (that I did know).
/M
--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnus@therning.org Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/beginners/attachments/20101019/6156a294/signature.bin
More information about the Beginners
mailing list