Names for small functions: just say no... Re: Data.List.join
u.stenzel at web.de
Thu Nov 9 18:32:39 EST 2006
Jon Fairbairn wrote:
> But not all patterns deserve names. To give a
> reductio-ad-absurdam sort of analogy, suppose someone looked
> at a lot of C and came to the conclusion that ???for (i=0,
> i++, ...)??? occurred in 90% of programmes. Were they to
> reason that it would be worth #defining a macro FORI(...)
> and using that instead, I suspect that the suggestion would
> be roundly dismissed.
Well, I presume you actually meant 'for( i=0; ... ; i++ )', an error
which would have been avoided by using a macro. Also, a macro would
have liberated you of the choice between '++i' and 'i++', where '++i' is
often more efficient (at least in C++). And in C++, you're encouraged
to use std::for_each anyway, which is the C++ way to spell 'mapM_'.
Which would make your point kinda moot, but I'm not really convinced
that arguments from a souped up assembly language can be used to make a
point about Haskell.
> Of course not, but you have to be careful what you deduce
> from the old code, particularly if you are reasoning from
> "most code is like this", because that doesn't tell you
> whether most code should be like that or most code should
> have been written differently.
Exactly! To state it explicitly: it seems, 'intersperse' is either
used at type 'String' or in conjunction with pretty printing. Or in
other words, either with pretty printing or with ugly printing.
Therefore, the right thing to do is not to provide an ugly printing
idiom, but to improve Text.PrettyPrint to the point where it is easier
to use than plain strings. A tutorial should be enough to achieve that.
In fact, if I had a better understanding of the behaviour of
Text.PrettyPrint, and if there was a way to easily format tables, I'd
never mess with strings for human readable output.
It is better to have loved a short man than never to have loved a tall.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/libraries/attachments/20061110/806397a6/attachment-0001.bin
More information about the Libraries