summaryrefslogtreecommitdiff
path: root/libraries/ghc-boot/GHC/Data/ShortText.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ghc-boot/GHC/Data/ShortText.hs')
-rw-r--r--libraries/ghc-boot/GHC/Data/ShortText.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/libraries/ghc-boot/GHC/Data/ShortText.hs b/libraries/ghc-boot/GHC/Data/ShortText.hs
index 9ea261435f..aa5a50ce7f 100644
--- a/libraries/ghc-boot/GHC/Data/ShortText.hs
+++ b/libraries/ghc-boot/GHC/Data/ShortText.hs
@@ -29,6 +29,7 @@ module GHC.Data.ShortText (
-- * ShortText
ShortText(..),
-- ** Conversion to and from String
+ singleton,
pack,
unpack,
-- ** Operations
@@ -77,6 +78,10 @@ byteLength st = SBS.length $ contents st
pack :: String -> ShortText
pack s = ShortText $ utf8EncodeShortByteString s
+-- | Create a singleton
+singleton :: Char -> ShortText
+singleton s = pack [s]
+
-- | /O(n)/ Convert a 'ShortText' into a 'String'.
unpack :: ShortText -> String
unpack st = utf8DecodeShortByteString $ contents st