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

Ken Bateman novadenizen at gmail.com
Thu Nov 24 20:07:56 UTC 2016


Maybe you want to use Data.Serialize?  Encode to and from a bytestring.

On Nov 24, 2016 1:24 PM, "Michael Snoyman" <michael at snoyman.com> wrote:

> It can't be done. Instances of Storable need to have a fixed serialized
> size, and Text values don't.
>
> On Thu, Nov 24, 2016, 8:21 PM 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.
>
>
> _______________________________________________
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20161124/dc6e24d4/attachment.html>


More information about the Haskell-Cafe mailing list