On Friday 04 June 2010 00:41:58, Bryan O'Sullivan wrote:
> On Thu, Jun 3, 2010 at 9:16 AM, Daniel Fischer 
<daniel.is.fisc...@web.de>wrote:
> > String can be quite memory efficient. As a stupid example,
> >
> > length (replicate 10000000 'a')
> >
> > will need less memory than the equivalents using ByteString or Text.
>
> Actually, this will be fused with Data.Text, and should execute more
> quickly and in less space than String.

Right, forgot about fusion. However, that requires the code to be compiled 
with optimisations, I think (well, one should never compile ByteString or 
Text code without).

In which case

{-# RULES
"length/replicate" forall n x. length (replicate n x) = max 0 n
   #-}

would be at least as good as the Data.Text thing ;)

Or, to be more fair, if you use Data.List.Stream, it should be fused too 
and be equally efficient as Data.Text.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to