text 0.11.1.13 → 0.11.2.0
raw patch · 4 files changed
+90/−8 lines, 4 filesdep ~test-framework
Dependency ranges changed: test-framework
Files
- Data/Text.hs +21/−2
- Data/Text/Fusion/Common.hs +35/−2
- Data/Text/Lazy.hs +21/−2
- text.cabal +13/−2
Data/Text.hs view
@@ -1,9 +1,9 @@-{-# LANGUAGE BangPatterns, CPP, Rank2Types, UnboxedTuples #-}+{-# LANGUAGE BangPatterns, CPP, MagicHash, Rank2Types, UnboxedTuples #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | -- Module : Data.Text--- Copyright : (c) 2009, 2010, 2011 Bryan O'Sullivan,+-- Copyright : (c) 2009, 2010, 2011, 2012 Bryan O'Sullivan, -- (c) 2009 Duncan Coutts, -- (c) 2008, 2009 Tom Harper --@@ -222,6 +222,12 @@ import qualified Data.Text.Lazy as L import Data.Int (Int64) #endif+#if __GLASGOW_HASKELL__ >= 702+import qualified GHC.CString as GHC+#else+import qualified GHC.Base as GHC+#endif+import GHC.Prim (Addr#) -- $strict --@@ -371,6 +377,19 @@ unpack :: Text -> String unpack = S.unstreamList . stream {-# INLINE [1] unpack #-}++-- | /O(n)/ Convert a literal string into a Text.+unpackCString# :: Addr# -> Text+unpackCString# addr# = unstream (S.streamCString# addr#)+{-# NOINLINE unpackCString# #-}++{-# RULES "TEXT literal" forall a.+ unstream (S.streamList (L.map safe (GHC.unpackCString# a)))+ = unpackCString# a #-}++{-# RULES "TEXT literal UTF8" forall a.+ unstream (S.streamList (L.map safe (GHC.unpackCStringUtf8# a)))+ = unpackCString# a #-} -- | /O(1)/ Convert a character into a Text. Subject to fusion. -- Performs replacement on invalid scalar values.
Data/Text/Fusion/Common.hs view
@@ -1,7 +1,7 @@-{-# LANGUAGE BangPatterns, Rank2Types #-}+{-# LANGUAGE BangPatterns, MagicHash, Rank2Types #-} -- | -- Module : Data.Text.Fusion.Common--- Copyright : (c) Bryan O'Sullivan 2009+-- Copyright : (c) Bryan O'Sullivan 2009, 2012 -- -- License : BSD-style -- Maintainer : bos@serpentine.com, rtomharper@googlemail.com,@@ -17,6 +17,7 @@ singleton , streamList , unstreamList+ , streamCString# -- * Basic interface , cons@@ -104,10 +105,13 @@ (&&), fromIntegral, otherwise) import qualified Data.List as L import qualified Prelude as P+import Data.Bits (shiftL) import Data.Int (Int64) import Data.Text.Fusion.Internal import Data.Text.Fusion.CaseMapping (foldMapping, lowerMapping, upperMapping) import Data.Text.Fusion.Size+import GHC.Prim (Addr#, chr#, indexCharOffAddr#, ord#)+import GHC.Types (Char(..), Int(..)) singleton :: Char -> Stream Char singleton c = Stream next False 1@@ -130,6 +134,35 @@ {-# INLINE [0] unstreamList #-} {-# RULES "STREAM streamList/unstreamList fusion" forall s. streamList (unstreamList s) = s #-}++-- | Stream the UTF-8-like packed encoding used by GHC to represent+-- constant strings in generated code.+--+-- This encoding uses the byte sequence "\xc0\x80" to represent NUL,+-- and the string is NUL-terminated.+streamCString# :: Addr# -> Stream Char+streamCString# addr = Stream step 0 unknownSize+ where+ step !i+ | b == 0 = Done+ | b <= 0x7f = Yield (C# b#) (i+1)+ | b <= 0xdf = let !c = chr $ ((b-0xc0) `shiftL` 6) + next 1+ in Yield c (i+2)+ | b <= 0xef = let !c = chr $ ((b-0xe0) `shiftL` 12) ++ (next 1 `shiftL` 6) ++ next 2+ in Yield c (i+3)+ | otherwise = let !c = chr $ ((b-0xf0) `shiftL` 18) ++ (next 1 `shiftL` 12) ++ (next 2 `shiftL` 6) ++ next 3+ in Yield c (i+4)+ where b = I# (ord# b#)+ next n = I# (ord# (at# (i+n))) - 0x80+ !b# = at# i+ at# (I# i#) = indexCharOffAddr# addr i#+ chr (I# i#) = C# (chr# i#)+{-# INLINE [0] streamCString# #-} -- ---------------------------------------------------------------------------- -- * Basic stream functions
Data/Text/Lazy.hs view
@@ -1,8 +1,8 @@ {-# OPTIONS_GHC -fno-warn-orphans #-}-{-# LANGUAGE BangPatterns, CPP #-}+{-# LANGUAGE BangPatterns, MagicHash, CPP #-} -- | -- Module : Data.Text.Lazy--- Copyright : (c) 2009, 2010 Bryan O'Sullivan+-- Copyright : (c) 2009, 2010, 2012 Bryan O'Sullivan -- -- License : BSD-style -- Maintainer : bos@serpentine.com, rtomharper@googlemail.com,@@ -217,6 +217,12 @@ import Data.Text.Internal (firstf, safe, textP) import qualified Data.Text.Util as U import Data.Text.Lazy.Search (indices)+#if __GLASGOW_HASKELL__ >= 702+import qualified GHC.CString as GHC+#else+import qualified GHC.Base as GHC+#endif+import GHC.Prim (Addr#) -- $fusion --@@ -350,6 +356,19 @@ unpack :: Text -> String unpack t = S.unstreamList (stream t) {-# INLINE [1] unpack #-}++-- | /O(n)/ Convert a literal string into a Text.+unpackCString# :: Addr# -> Text+unpackCString# addr# = unstream (S.streamCString# addr#)+{-# NOINLINE unpackCString# #-}++{-# RULES "TEXT literal" forall a.+ unstream (S.streamList (L.map safe (GHC.unpackCString# a)))+ = unpackCString# a #-}++{-# RULES "TEXT literal UTF8" forall a.+ unstream (S.streamList (L.map safe (GHC.unpackCStringUtf8# a)))+ = unpackCString# a #-} -- | /O(1)/ Convert a character into a Text. Subject to fusion. -- Performs replacement on invalid scalar values.
text.cabal view
@@ -1,5 +1,5 @@ name: text-version: 0.11.1.13+version: 0.11.2.0 homepage: https://github.com/bos/text bug-reports: https://github.com/bos/text/issues synopsis: An efficient packed Unicode text type.@@ -31,6 +31,15 @@ the @text-icu@ package: <http://hackage.haskell.org/package/text-icu> .+ —— RELEASE NOTES ——+ .+ Changes in 0.11.2.0:+ .+ * String literals are now converted directly from the format in+ which GHC stores them into 'Text', without an intermediate+ transformation through 'String', and without inlining of+ conversion code at each site where a string literal is declared.+ . license: BSD3 license-file: LICENSE author: Bryan O'Sullivan <bos@serpentine.com>@@ -152,11 +161,13 @@ base >= 4 && < 5, bytestring >= 0.9 && < 0.10, deepseq >= 1.1,+ ghc-prim, directory >= 1.0 && < 1.2,+ ghc-prim, random >= 1.0 && < 1.1, QuickCheck >= 2.4 && < 2.5, HUnit >= 1.2 && < 1.3,- test-framework >= 0.4 && < 0.5,+ test-framework >= 0.4 && < 0.7, test-framework-quickcheck2 >= 0.2 && < 0.3, test-framework-hunit >= 0.2 && < 0.3