[Haskell-beginners] Flying Dutchman sailing blind

Stephen Tetley stephen.tetley at gmail.com
Tue Oct 5 07:46:28 EDT 2010


On 5 October 2010 09:06, Jeroen van Maanen <jeroen at lexau.org> wrote:

>
> P.S. For an idea of what is living in the snail pit, have a look at:
>
>  http://lexau.svn.sourceforge.net/viewvc/lexau/branches/totem/src/LExAu/Pipeline/Concurrent.hs?view=markup
>  http://lexau.svn.sourceforge.net/viewvc/lexau/branches/totem/src/LExAu/Model/HistoryTree.hs?view=markup
>
> (I know, HistoryTree.hs badly needs to be split up into smaller modules.)

A minor style tip...

You are using ShowS family functions (showString, showChar) to
generate strings which is good as it avoids (++). However, to make the
code clearer you might want to code up a little helper library with
ShowS versions of the usual pretty print combinators.

e.g. all the functions like parens:

parens :: ShowS -> ShowS
parens s = showChar '(' . s . showChar ')'


Having a library of these functions usually pays off (I think there is
one on Hackage but I can't remember its name). You could use a pretty
printing library, but they are somewhat less efficient as the have to
do work measuring line lengths for fitting lines to screen width.

Best wishes

Stephen


More information about the Beginners mailing list