on master help sign in
Expose unpackCString#
6dfe977Bryan O'Sullivan
Data/Text.hs+2−1
@@ -191,6 +191,7 @@ module Data.Text
191
191
192 -- * Low level operations
192 -- * Low level operations
193 , copy
193 , copy
194+ , unpackCString#
194 ) where
195 ) where
195
196
196import Prelude (Char, Bool(..), Int, Maybe(..), String,
197import Prelude (Char, Bool(..), Int, Maybe(..), String,
@@ -220,7 +221,7 @@ import Data.Text.Encoding (decodeUtf8, encodeUtf8)
220import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
221import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
221import Data.Text.Internal.Private (span_)
222import Data.Text.Internal.Private (span_)
222import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text)
223import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text)
223−import Data.Text.Show (singleton, unpack)
224+import Data.Text.Show (singleton, unpack, unpackCString#)
224import qualified Prelude as P
225import qualified Prelude as P
225import Data.Text.Unsafe (Iter(..), iter, iter_, lengthWord16, reverseIter,
226import Data.Text.Unsafe (Iter(..), iter, iter_, lengthWord16, reverseIter,
226 reverseIter_, unsafeHead, unsafeTail)
227 reverseIter_, unsafeHead, unsafeTail)
Data/Text/Show.hs+5−1
@@ -17,6 +17,7 @@ module Data.Text.Show
17 (
17 (
18 singleton
18 singleton
19 , unpack
19 , unpack
20+ , unpackCString#
20 ) where
21 ) where
21
22
22import Control.Monad.ST (ST)
23import Control.Monad.ST (ST)
@@ -41,7 +42,10 @@ unpack :: Text -> String
41unpack = S.unstreamList . stream
42unpack = S.unstreamList . stream
42{-# INLINE [1] unpack #-}
43{-# INLINE [1] unpack #-}
43
44
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.
45unpackCString# :: Addr# -> Text
49unpackCString# :: Addr# -> Text
46unpackCString# addr# = unstream (S.streamCString# addr#)
50unpackCString# addr# = unstream (S.streamCString# addr#)
47{-# NOINLINE unpackCString# #-}
51{-# NOINLINE unpackCString# #-}