[Haskell-cafe] Instances for Data.Text

Bryan O'Sullivan bos at serpentine.com
Tue Sep 29 12:24:49 EDT 2009


On Tue, Sep 29, 2009 at 1:15 AM, Pasqualino "Titto" Assini <
tittoassini at gmail.com> wrote:

>
> This is a good point, I also need to make Data.Text an instance of a
> few basic classes and I am not sure that I did it correctly.
>
> So far I have:
>
> import Data.Text
>
> instance Binary Text where
>   put = put . encodeUtf8
>   get = liftM decodeUtf8 get
>

Well, independent of the implementation (yours seems fine, by the way), we
can't have Platform packages depend on non-Platform packages. The text
library isn't in a position to make it ready for inclusion there yet, but
it's getting close, and it might even get there before binary. So it's no
problem to write an NFData instance, but a Binary instance would be an
issue.

-- DOUBT: Is this correct also for Data.Text.Lazy ?
> instance NFData Text
>
> instance Serial Text where
>  -- DOUBT: is this efficient?
>  series   d   = [T.pack (series d :: String)]
> -- DOUBT: how to define this
>  coseries rs  = error "coseries"
>

What's Serial?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/199cd22e/attachment.html


More information about the Haskell-Cafe mailing list