1
1
{-# LANGUAGE BangPatterns, CPP, MagicHash, Rank2Types, UnboxedTuples, TypeFamilies #-}
2
- {-# OPTIONS_GHC -fno-warn-orphans #-}
3
- #if __GLASGOW_HASKELL__ >= 702
4
- {-# LANGUAGE Trustworthy #-}
5
- #endif
6
- -- Using TemplateHaskell in text unconditionally is unacceptable, as
7
- -- it's a GHC boot library. TemplateHaskellQuotes was added in 8.0, so
8
- -- this would seem to be a problem. However, GHC's policy of only
9
- -- needing to be able to compile itself from the last few releases
10
- -- allows us to use full-fat TH on older versions, while using THQ for
11
- -- GHC versions that may be used for bootstrapping.
12
- #if __GLASGOW_HASKELL__ >= 800
13
2
{-# LANGUAGE TemplateHaskellQuotes #-}
14
- #else
15
- {-# LANGUAGE TemplateHaskell #-}
16
- #endif
3
+ {-# LANGUAGE Trustworthy #-}
4
+
5
+ {-# OPTIONS_GHC -fno-warn-orphans #-}
17
6
18
7
-- |
19
8
-- Module : Data.Text
@@ -226,9 +215,7 @@ import qualified Data.Text.Array as A
226
215
import qualified Data.List as L
227
216
import Data.Binary (Binary (get , put ))
228
217
import Data.Monoid (Monoid (.. ))
229
- #if MIN_VERSION_base(4,9,0)
230
218
import Data.Semigroup (Semigroup (.. ))
231
- #endif
232
219
import Data.String (IsString (.. ))
233
220
import qualified Data.Text.Internal.Fusion as S
234
221
import qualified Data.Text.Internal.Fusion.Common as S
@@ -251,14 +238,10 @@ import qualified Data.Text.Lazy as L
251
238
import Data.Int (Int64 )
252
239
#endif
253
240
import GHC.Base (eqInt , neInt , gtInt , geInt , ltInt , leInt )
254
- #if MIN_VERSION_base(4,7,0)
255
241
import qualified GHC.Exts as Exts
256
- #endif
257
242
import qualified Language.Haskell.TH.Lib as TH
258
243
import qualified Language.Haskell.TH.Syntax as TH
259
- #if MIN_VERSION_base(4,7,0)
260
244
import Text.Printf (PrintfArg , formatArg , formatString )
261
- #endif
262
245
263
246
-- $setup
264
247
-- >>> import Data.Text
@@ -364,37 +347,23 @@ instance Ord Text where
364
347
instance Read Text where
365
348
readsPrec p str = [(pack x,y) | (x,y) <- readsPrec p str]
366
349
367
- #if MIN_VERSION_base(4,9,0)
368
- -- | Non-orphan 'Semigroup' instance only defined for
369
- -- @base-4.9.0.0@ and later; orphan instances for older GHCs are
370
- -- provided by
371
- -- the [semigroups](http://hackage.haskell.org/package/semigroups)
372
- -- package
373
- --
374
- -- @since 1.2.2.0
350
+ -- | @since 1.2.2.0
375
351
instance Semigroup Text where
376
352
(<>) = append
377
- #endif
378
353
379
354
instance Monoid Text where
380
355
mempty = empty
381
- #if MIN_VERSION_base(4,9,0)
382
- mappend = (<>) -- future-proof definition
383
- #else
384
- mappend = append
385
- #endif
356
+ mappend = (<>)
386
357
mconcat = concat
387
358
388
359
instance IsString Text where
389
360
fromString = pack
390
361
391
- #if MIN_VERSION_base(4,7,0)
392
362
-- | @since 1.2.0.0
393
363
instance Exts. IsList Text where
394
364
type Item Text = Char
395
365
fromList = pack
396
366
toList = unpack
397
- #endif
398
367
399
368
instance NFData Text where rnf ! _ = ()
400
369
@@ -442,13 +411,9 @@ instance TH.Lift Text where
442
411
liftTyped = TH. unsafeTExpCoerce . TH. lift
443
412
#endif
444
413
445
- #if MIN_VERSION_base(4,7,0)
446
- -- | Only defined for @base-4.7.0.0@ and later
447
- --
448
- -- @since 1.2.2.0
414
+ -- | @since 1.2.2.0
449
415
instance PrintfArg Text where
450
416
formatArg txt = formatString $ unpack txt
451
- #endif
452
417
453
418
packConstr :: Constr
454
419
packConstr = mkConstr textDataType " pack" [] Prefix
0 commit comments