on master help sign in
Add a Data instance for lazy Text.

--HG-- extra : convert_revision : 86f00007b44bdc1507a5d4ce90b63ba5cfbd8fb5

commit8b5710bb1806d39862bb90be093ce2ae0f1f8150 authorBryan O'Sullivan <bos@serpentine.com> dateFri 5 Feb 2010, 20:12 (17 years ago) parent760bce7
1 file changed+17−1
Data/Text/Lazy.hs+17−1
Data/Text/Lazy.hs+17−1
@@ -167,7 +167,7 @@ module Data.Text.Lazy
167167import Prelude (Char, Bool(..), Maybe(..), String,
168168 Eq(..), Ord(..), Read(..), Show(..),
169169 (&&), (+), (-), (.), ($), (++),
170− div, flip, fromIntegral, not, otherwise)
170+ div, error, flip, fromIntegral, not, otherwise)
171171import qualified Prelude as P
172172#if defined(HAVE_DEEPSEQ)
173173import Control.DeepSeq (NFData(..))
@@ -175,6 +175,12 @@ import Control.DeepSeq (NFData(..))
175175import Data.Int (Int64)
176176import qualified Data.List as L
177177import Data.Char (isSpace)
178+import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf))
179+#if __GLASGOW_HASKELL__ >= 612
180+import Data.Data (mkNoRepType)
181+#else
182+import Data.Data (mkNorepType)
183+#endif
178184import Data.Monoid (Monoid(..))
179185import Data.String (IsString(..))
180186import qualified Data.Text as T
@@ -216,6 +222,16 @@ instance NFData Text where
216222 rnf (Chunk _ ts) = rnf ts
217223#endif
218224
225+instance Data Text where
226+ gfoldl f z txt = z pack `f` (unpack txt)
227+ toConstr _ = error "Data.Text.Lazy.Text.toConstr"
228+ gunfold _ _ = error "Data.Text.Lazy.Text.gunfold"
229+#if __GLASGOW_HASKELL__ >= 612
230+ dataTypeOf _ = mkNoRepType "Data.Text.Lazy.Text"
231+#else
232+ dataTypeOf _ = mkNorepType "Data.Text.Lazy.Text"
233+#endif
234+
219235-- | /O(n)/ Convert a 'String' into a 'Text'.
220236--
221237-- This function is subject to array fusion.