[Haskell-cafe] how to get started: a text application

Graham Klyne GK at ninebynine.org
Fri Jun 25 10:42:24 EDT 2004


At 16:14 25/06/04 +0300, Max Ischenko wrote:
>>Many (most?) Wiki engines use straightforward regex substitution to convert
>>the text source into HTML, rather than implement a
>>lexer/parser/pretty-printer combination. Obviously this makes for a fairly
>>simple implementation. Mind you, some of the regex's are quite complex...
>
>You're right, even the Markdown itself implemented that way (Perl).
>Of course, building unnecessarily layers of abstraction is no good but my 
>goals are more educational that practial. Plus, sometimes you need to 
>complicate things to simplify them. ;-)

On reflection, I think there's a strong case for doing it this way (i.e. 
with a separate tokenizer) in Haskell, even if the tokenization is very 
simple, because it helps to separate some of the character-level issues 
from the remaining program logic.  Any spurious detail that can be 
separated from the core logic makes the core easier to understand.  Divide 
and rule!  And, if I understand correctly, Haskell's lazy evaluation should 
mean that there's little or no penalty for doing this, even though it looks 
as if you're generating substantial intermediate data.

...

BTW, for a project like this, be very aware of the cost of using ++ to 
append to a sequence.  Look at the ShowS type in the standard Prelude 
(PreludeText).  I also made some notes about this [1].

#g
--

[1] http://www.ninebynine.org/Software/Learning-Haskell-Notes.html#UsingShowS



------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact



More information about the Haskell-Cafe mailing list