diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2022-05-31 13:34:11 +0200 |
---|---|---|
committer | doyougnu <jeffrey.young@iohk.io> | 2022-06-13 13:42:47 -0400 |
commit | 6b8e07a79c29f961e3c4e8843a34c087ef036f8b (patch) | |
tree | a09b7b47c3b990726222cb491dad7a70f104d63b | |
parent | 00bc857c24a240ccd0c8b0558198640afd535579 (diff) | |
download | haskell-6b8e07a79c29f961e3c4e8843a34c087ef036f8b.tar.gz |
ShortText: add singleton
-rw-r--r-- | libraries/ghc-boot/GHC/Data/ShortText.hs | 5 |
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 2b3038ccfc..c9e754de79 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 @@ -76,6 +77,10 @@ byteLength st = SBS.length $ contents st pack :: String -> ShortText pack s = unsafeDupablePerformIO $ 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 |