[Haskell-cafe] Creating a instance for (Storable Text)

Chris Wong lambda.fairy at gmail.com
Fri Nov 25 01:59:28 UTC 2016

Since Text is represented as UTF-16 underneath, you can retrieve the
length in terms of 16-bit code units.

I don't think you'll be able to mmap them though, since the backing
array may be moved by the garbage collector.

See https://hackage.haskell.org/package/text-

On Fri, Nov 25, 2016 at 7:20 AM, Cody Goodman
<codygman.consulting at gmail.com> wrote:
> Any ideas on how I'd write this instance? I know for it to be storable it
> needs a size, couldn't I just get the length of the text? Has anyone did
> anything similar?
> I ran into a surprise when trying to use storable-record and derive-storable
> and tried using them with a record that contained a Text field.
> My end goal is having a vector of records that could contain Text, UTCTime,
> or other similarly complex types which I can write as an mmap to disk and
> then read back to the original format.
> Thanks!
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.

Chris Wong (https://lambda.xyz)

"I had not the vaguest idea what this meant and when I could not
remember the words, my tutor threw the book at my head, which did not
stimulate my intellect in any way." -- Bertrand Russell

More information about the Haskell-Cafe mailing list