on master help sign in
Expose unpackCString#
commit6dfe97711b40b01a64dba8f3438137b3480889a4 authorBryan O'Sullivan <bos@serpentine.com> dateTue 26 May 2015, 22:46 (11 years ago) parent4ec9aaa
2 files changed+7−2
Data/Text.hs+2−1 Data/Text/Show.hs+5−1
Data/Text.hs+2−1
@@ -191,6 +191,7 @@ module Data.Text
191191
192192 -- * Low level operations
193193 , copy
194+ , unpackCString#
194195 ) where
195196
196197import Prelude (Char, Bool(..), Int, Maybe(..), String,
@@ -220,7 +221,7 @@ import Data.Text.Encoding (decodeUtf8, encodeUtf8)
220221import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
221222import Data.Text.Internal.Private (span_)
222223import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text)
223−import Data.Text.Show (singleton, unpack)
224+import Data.Text.Show (singleton, unpack, unpackCString#)
224225import qualified Prelude as P
225226import Data.Text.Unsafe (Iter(..), iter, iter_, lengthWord16, reverseIter,
226227 reverseIter_, unsafeHead, unsafeTail)
Data/Text/Show.hs+5−1
@@ -17,6 +17,7 @@ module Data.Text.Show
1717 (
1818 singleton
1919 , unpack
20+ , unpackCString#
2021 ) where
2122
2223import Control.Monad.ST (ST)
@@ -41,7 +42,10 @@ unpack :: Text -> String
4142unpack = S.unstreamList . stream
4243{-# INLINE [1] unpack #-}
4344
44−-- | /O(n)/ Convert a literal string into a Text. Subject to fusion.
45+-- | /O(n)/ Convert a literal string into a 'Text'. Subject to
46+-- fusion.
47+--
48+-- This is exposed solely for people writing GHC rewrite rules.
4549unpackCString# :: Addr# -> Text
4650unpackCString# addr# = unstream (S.streamCString# addr#)
4751{-# NOINLINE unpackCString# #-}