Skip to content

Commit

Permalink
Expose unpackCString#
Browse files Browse the repository at this point in the history
  • Loading branch information
bos committed May 27, 2015
1 parent 4ec9aaa commit 6dfe977
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Data/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ module Data.Text

-- * Low level operations
, copy
, unpackCString#
) where

import Prelude (Char, Bool(..), Int, Maybe(..), String,
Expand Down Expand Up @@ -220,7 +221,7 @@ import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
import Data.Text.Internal.Private (span_)
import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text)
import Data.Text.Show (singleton, unpack)
import Data.Text.Show (singleton, unpack, unpackCString#)
import qualified Prelude as P
import Data.Text.Unsafe (Iter(..), iter, iter_, lengthWord16, reverseIter,

This comment has been minimized.

Copy link
@yankton

yankton Jan 21, 2017

G

reverseIter_, unsafeHead, unsafeTail)
Expand Down
6 changes: 5 additions & 1 deletion Data/Text/Show.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Data.Text.Show
(
singleton
, unpack
, unpackCString#
) where

import Control.Monad.ST (ST)
Expand All @@ -41,7 +42,10 @@ unpack :: Text -> String
unpack = S.unstreamList . stream
{-# INLINE [1] unpack #-}

-- | /O(n)/ Convert a literal string into a Text. Subject to fusion.
-- | /O(n)/ Convert a literal string into a 'Text'. Subject to
-- fusion.
--
-- This is exposed solely for people writing GHC rewrite rules.
unpackCString# :: Addr# -> Text
unpackCString# addr# = unstream (S.streamCString# addr#)
{-# NOINLINE unpackCString# #-}
Expand Down

0 comments on commit 6dfe977

Please sign in to comment.