@@ -210,8 +210,8 @@ import Control.DeepSeq (NFData(..))
210import Data.Int (Int64)
210import Data.Int (Int64)
211import qualified Data.List as L
211import qualified Data.List as L
212import Data.Char (isSpace)
212import Data.Char (isSpace)
213−import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
213+import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf), constrIndex,
214−import Data.Data (mkNoRepType)
214+ Constr, mkConstr, DataType, mkDataType, Fixity(Prefix))
215import Data.Monoid (Monoid(..))
215import Data.Monoid (Monoid(..))
216import Data.String (IsString(..))
216import Data.String (IsString(..))
217import qualified Data.Text as T
217import qualified Data.Text as T
@@ -353,11 +353,24 @@ instance NFData Text where
353 rnf (Chunk _ ts) = rnf ts
353 rnf (Chunk _ ts) = rnf ts
356+-- | This instance preserves data abstraction at the cost of inefficiency.
357+-- We omit reflection services for the sake of data abstraction.
359+-- This instance was created by copying the updated behavior of
360+-- @"Data.Text".@'Data.Text.Text'
356instance Data Text where
361instance Data Text where
357 gfoldl f z txt = z pack `f` (unpack txt)
362 gfoldl f z txt = z pack `f` (unpack txt)
358− toConstr _ = error "Data.Text.Lazy.Text.toConstr"
363+ toConstr _ = packConstr
364+ gunfold k z c = case constrIndex c of
359− gunfold _ _ = error "Data.Text.Lazy.Text.gunfold"
366+ _ -> error "Data.Text.Lazy.Text.gunfold"
360− dataTypeOf _ = mkNoRepType "Data.Text.Lazy.Text"
367+ dataTypeOf _ = textDataType
370+packConstr = mkConstr textDataType "pack" [] Prefix
372+textDataType :: DataType
373+textDataType = mkDataType "Data.Text.Lazy.Text" [packConstr]
362-- | /O(n)/ Convert a 'String' into a 'Text'.
375-- | /O(n)/ Convert a 'String' into a 'Text'.