@@ -0,0 +1,53 @@
1+{-# OPTIONS_GHC -fno-warn-orphans #-}
12+import Data.String (IsString(..))
13+import qualified Data.Text.Fusion as S
14+import Data.Text.Fusion.Internal as S
15+import Data.Text.Lazy.Fusion
16+import Data.Text.Lazy.Internal
18+instance Eq Text where
19+ t1 == t2 = stream t1 `S.eq` stream t2
21+instance Show Text where
22+ showsPrec p ps r = showsPrec p (unpack ps) r
24+instance Read Text where
25+ readsPrec p str = [(pack x,y) | (x,y) <- readsPrec p str]
27+instance IsString Text where
30+-- | /O(n)/ Convert a 'String' into a 'Text'.
32+-- This function is subject to array fusion.
33+pack :: String -> Text
34+pack = unstream . S.streamList
35+{-# INLINE [1] pack #-}
37+-- | /O(n)/ Convert a 'Text' into a 'String'.
38+-- Subject to array fusion.
39+unpack :: Text -> String
40+unpack = unstreamList . stream
41+{-# INLINE [1] unpack #-}
43+-- | /O(n\/c)/ Append two 'Text's
44+append :: Text -> Text -> Text
45+append xs ys = foldrChunks Chunk ys xs
49+"TEXT append -> fused" [~1] forall t1 t2.
50+ append t1 t2 = unstream (S.append (stream t1) (stream t2))
51+"TEXT append -> unfused" [1] forall t1 t2.
52+ unstream (S.append (stream t1) (stream t2)) = append t1 t2