Commits

Bryan O'Sullivan committed 738a7c9

Add a Data instance for lazy Text.

Comments (0)

Files changed (1)

Data/Text/Lazy.hs

 import Prelude (Char, Bool(..), Maybe(..), String,
                 Eq(..), Ord(..), Read(..), Show(..),
                 (&&), (+), (-), (.), ($), (++),
-                div, flip, fromIntegral, not, otherwise)
+                div, error, flip, fromIntegral, not, otherwise)
 import qualified Prelude as P
 #if defined(HAVE_DEEPSEQ)
 import Control.DeepSeq (NFData(..))
 import Data.Int (Int64)
 import qualified Data.List as L
 import Data.Char (isSpace)
+import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
+#if __GLASGOW_HASKELL__ >= 612
+import Data.Data (mkNoRepType)
+#else
+import Data.Data (mkNorepType)
+#endif
 import Data.Monoid (Monoid(..))
 import Data.String (IsString(..))
 import qualified Data.Text as T
     rnf (Chunk _ ts) = rnf ts
 #endif
 
+instance Data Text where
+  gfoldl f z txt = z pack `f` (unpack txt)
+  toConstr _     = error "Data.Text.Lazy.Text.toConstr"
+  gunfold _ _    = error "Data.Text.Lazy.Text.gunfold"
+#if __GLASGOW_HASKELL__ >= 612
+  dataTypeOf _   = mkNoRepType "Data.Text.Lazy.Text"
+#else
+  dataTypeOf _   = mkNorepType "Data.Text.Lazy.Text"
+#endif
+
 -- | /O(n)/ Convert a 'String' into a 'Text'.
 --
 -- This function is subject to array fusion.