|Subject:||[Haskell-cafe] Re: could we get a Data instance for Data.Text.Text?|
|Date:||Tue, 26 Jan 2010 11:52:34 -0600|
Attached is my new and improved patch to add a Data instance to Data.Text. The patch just adds:
+-- This instance preserves data abstraction at the cost of inefficiency.
+-- We omit reflection services for the sake of data abstraction.
+instance Data Text where
+ gfoldl f z txt = z pack `f` (unpack txt)
+ toConstr _ = error "toConstr"
+ gunfold _ _ = error "gunfold"
+ dataTypeOf _ = mkNoRepType "Data.Text.Text"
Which is based on what the Data instances for Set and Map do:
Yay for cargo culting!
It seems like this is better than nothing, possibly the correct answer, and if someone does decide to add better instances for toConstr and gunfold in the future, nothing should break? For happstack-data, I think we only need dataTypeOf.
The instance I posted before definitely did not have valid toConstr / gunfold instances, so I think we would have noticed if we were actually trying to use them..
On Fri, Jan 22, 2010 at 4:24 PM, Jeremy Shaw <[email protected]> wrote:
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
|<Prev in Thread]||Current Thread||[Next in Thread>|
|Previous by Date:||Re: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text?, Jeremy Shaw|
|Next by Date:||Re: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text?, Felipe Lessa|
|Previous by Thread:||Re: [Haskell-cafe] could we get a Data instance for Data.Text.Text?, Neil Brown|
|Next by Thread:||Re: [Haskell-cafe] Re: could we get a Data instance for Data.Text.Text?, Felipe Lessa|
|Indexes:||[Date] [Thread] [Top] [All Lists]|