<p dir="ltr">Edward Kmett did some work with things he called "ropes" <a href="https://hackage.haskell.org/package/rope">https://hackage.haskell.org/package/rope</a> that can be efficient for some byte string manipulations. There may be other good choices.</p>
<div class="gmail_quote">On Jul 11, 2016 1:42 PM, "Bardur Arantsson" <<a href="mailto:spam@scientician.net">spam@scientician.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 07/11/2016 04:28 PM, Stephen Tetley wrote:<br>
> On 11 July 2016 at 13:54, David Fox <<a href="mailto:dsf@seereason.com">dsf@seereason.com</a>> wrote:<br>
><br>
>><br>
>> When I mentioned some of this, I was told "different data structures for<br>
>> different purposes", which sort of makes sense, but honestly if Haskell is a<br>
>> language where you have to sit down and choose a representation every time<br>
>> you want to build some text, I get a bit discouraged.<br>
><br>
> Don't C# and Java have StringBuilder classes (different to their<br>
> regular String types) for this as well?<br>
<br>
Yes, they do.<br>
<br>
If you just naively do<br>
<br>
   String s = "";<br>
   for (int i = 0; i < 1000000; i++) {<br>
       s = s + "hello";<br>
   }<br>
<br>
in Java you'll also get terrible performance (O(n^2)) as opposed to the<br>
equivalent code using StringBuilder which would be O(n). This does not<br>
change if you use e.g. Text/ByteString/Vector in Haskell.<br>
<br>
In Haskell, I could certainly imagine List[Char] being more performant<br>
than copying huge chunks of memory over and over... even though List<br>
traversal *is* generally slow.<br>
<br>
(Of course the actual performance depends on lots and lots of specifics.)<br>
<br>
><br>
> Maybe imperative OO is also antithetical to efficient strings...<br>
<br>
Bad algorithms and data structures are antithetical to efficient strings :).<br>
<br>
Regards,<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>