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

Neil Brown nccb2 at kent.ac.uk
Sat Jan 23 09:55:01 EST 2010

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:

   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.



More information about the Haskell-Cafe mailing list