[web-devel] [Yesod] How to write a field as binary data column.

Felipe Almeida Lessa felipe.lessa at gmail.com
Mon Dec 27 13:38:51 CET 2010


2010/12/27 いとうかつとし <cutsea110 at gmail.com>:
> I tryed ByteString import from Data.ByteString.
> Rather, This field's type is Data.ByteString.Internal.ByteString,
> on the other hand, fileContent of posted file's content is
> Data.ByteString.Lazy.Internal.ByteString.
> then, i translateed by B.concat . L.toChunks
> imported from Data.ByteString as B and Data.ByteString.Lazy as L.
> 1. this is right solution?
> 2. could the yesod framework automatically transform lazy <=> strict?
>    because i think posted file's content is always lazy, but we serialize
> the content as strict.

1. Yes, I think it is the right solution to convert lazy to strict bytestrings.

2. No, because sometimes you want one, and sometimes you want the
other.  And converting is a potentially costly operation.

I haven't tried and I don't know if there are any bad/good
consequences, but you may try using a lazy bytestring in your model.
In other words, use lazy bytestrings everywhere.

Cheers,

-- 
Felipe.



More information about the web-devel mailing list