[Haskell-cafe] Data.ByteString.dropWhile
Roman Leshchinskiy
rl at cse.unsw.edu.au
Tue Jul 10 01:47:57 EDT 2007
Thomas Conway wrote:
> Well, maybe I shoud be asking a higher level question then.
>
> I have a function
>
> tidy = reverse . dropWhile punk . reverse . dropWhile punk
> where
> punk = isPunctuation . chr . fromIntegral
>
> which is leading to a significant amount of allocation, and you can see
> why.
>
> The way I'd like to write it is
>
> tidy = dropWhile punk . dropWhileEnd punk
> where ....
>
> which has the obvious advantage of avoiding quite a bit of
> intermediate allocation.
>
> Is there a another way?
>
> I note that since I'm using a nice declarative language, the compiler
> CLEARLY should be transforming the first form into the second. :-)
The NDP library will implement this kind of fusion at some point
(hopefully this year). We have a fairly clear idea of how to do it but
not enough time.
Roman
More information about the Haskell-Cafe
mailing list