Haskell Platform Proposal: add the 'text' library

Bryan O'Sullivan bos at serpentine.com
Tue Oct 5 13:42:42 EDT 2010

On Mon, Oct 4, 2010 at 10:04 AM, Ian Lynagh <igloo at earth.li> wrote:

> Yup, that fixes that case, but this one still segfaults (on a
> 32bit platform):

Ah yes. I was doing the wrong kind of overflow check, so I got lucky with
the first fix on your initial test case.

There were a few other Int overflow candidates that I also fixed along the
way. What needs a deeper look is the handling of arithmetic in the internal
module Data.Text.Internal.Size. On a 32-bit machine, it should be fairly
easy to overflow those size calculations, but there are cases where you can
overflow and at least in theory still have a safe result. For instance:

take 3 (replicate 10 (replicate (maxBound `div` 2) "a"))

I'd be fine with this either throwing an error or returning "aaa", but right
now its behaviour is not likely to be so friendly.

The extra checks needed for overflow detection shouldn't have a noticeable
performance impact: there's an expensive div-test-and-branch required, but
the calculation should only occur once per fused loop (not per iteration).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20101005/5a0b79e9/attachment.html

More information about the Libraries mailing list