haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] could we get a Data instance for Data.Text.Text?

Subject: Re: [Haskell-cafe] could we get a Data instance for Data.Text.Text?
From: Neil Brown
Date: Sat, 23 Jan 2010 14:55:01 +0000
Jeremy Shaw wrote:
Hello,

Would it be possible to get a Data instance for Data.Text.Text? This would allow us to create a Serialize instance of Text for use with happstack -- which would be extremely useful.
Last time this came up, I had a look at providing a Data instance for Text, and I "got as far as needing a Data instance for ByteString#, accompanied by an error I don't fully understand, but I think is telling me that things involving magic hashes are magic:

Data/Text/Array.hs:104:35:
  Couldn't match kind `#' against `*'
  When matching the kinds of `ByteArray# :: #' and `d :: *'
    Expected type: d
    Inferred type: ByteArray#
  In the first argument of `z', namely `Array' "

The problem with a Data instance for Text is that it is using this ByteArray# type, which can't easily interact with the Data type-class because it's a special type. I would suggest providing a Data instance for ByteArray#, but I don't think that's possible either. As far as I can understand it all, your Data instance is probably the closest you are going to get to having a decent Data instance without something else (GHC/SYB) changing significantly.

Thanks,

Neil.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>