Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Flying Dutchman sailing blind (Bas van Dijk)
----------------------------------------------------------------------
Message: 1
Date: Wed, 6 Oct 2010 09:18:14 +0200
From: Bas van Dijk <[email protected]>
Subject: Re: [Haskell-beginners] Flying Dutchman sailing blind
To: Stephen Tetley <[email protected]>, Jeroen van Maanen
<[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=UTF-8
On Tue, Oct 5, 2010 at 1:46 PM, Stephen Tetley <[email protected]> wrote:
> On 5 October 2010 09:06, Jeroen van Maanen <[email protected]> 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
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
Instead of a ShowS you might want to use a DString[1] which is
basically a newtype wrapper around a ShowS. The advantage of a DString
is that it has an instance for IsString which allows you to write
overloaded string literals of type DString.
You might also take a look at string-combinators[2] which provides
handy polymorphic functions to build and combine string-like values.
For example it provides:
paren :: (Monoid s, IsString s) => s -> s
(I've no idea why I named this 'paren' instead of 'parens' I will
change this in the next version)
Regards,
Bas
[1] http://hackage.haskell.org/package/dstring
[2] http://hackage.haskell.org/package/string-combinators
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 28, Issue 15
*****************************************