ghc-boot-9.10.3: Shared functionality between GHC and its boot libraries

Safe Haskell | None
Language | Haskell2010

GHC.Data.ShortText

Contents

- ShortText
  - Conversion to and from String
  - Operations

Description

An Unicode string for internal GHC use. Meant to replace String in places where being a lazy linked is not very useful and a more memory efficient data structure is desirable.

Synopsis

- newtype ShortText = ShortText {
  - contents :: ShortByteString
  }
- singleton :: Char -> ShortText
- pack :: String -> ShortText
- unpack :: ShortText -> String
- codepointLength :: ShortText -> Int
- byteLength :: ShortText -> Int
- null :: ShortText -> Bool
- splitFilePath :: ShortText -> [ShortText]
- head :: ShortText -> Char
- stripPrefix :: ShortText -> ShortText -> Maybe ShortText

# ShortText

newtype ShortText Source #

A `ShortText` is a modified UTF-8 encoded string meant for short strings like file paths, module descriptions, etc.

Constructors

ShortText |

Fields

- contents :: ShortByteString

#### Instances

Instances details

Binary ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods put :: ShortText -> Put Source # get :: Get ShortText Source # putList :: [ShortText] -> Put Source #
NFData ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods rnf :: ShortText -> () Source #
Monoid ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods mempty :: ShortText # mappend :: ShortText -> ShortText -> ShortText # mconcat :: [ShortText] -> ShortText #
Semigroup ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods (<>) :: ShortText -> ShortText -> ShortText # sconcat :: NonEmpty ShortText -> ShortText # stimes :: Integral b => b -> ShortText -> ShortText #
IsString ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods fromString :: String -> ShortText #
Show ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods showsPrec :: Int -> ShortText -> ShowS # show :: ShortText -> String # showList :: [ShortText] -> ShowS #
Eq ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods (==) :: ShortText -> ShortText -> Bool # (/=) :: ShortText -> ShortText -> Bool #
Ord ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods compare :: ShortText -> ShortText -> Ordering # (<) :: ShortText -> ShortText -> Bool # (<=) :: ShortText -> ShortText -> Bool # (>) :: ShortText -> ShortText -> Bool # (>=) :: ShortText -> ShortText -> Bool # max :: ShortText -> ShortText -> ShortText # min :: ShortText -> ShortText -> ShortText #

## Conversion to and from String

singleton :: Char -> ShortText Source #

Create a singleton

pack :: String -> ShortText Source #

O(n) Convert a `String` into a `ShortText`.

unpack :: ShortText -> String Source #

O(n) Convert a `ShortText` into a `String`.

## Operations

codepointLength :: ShortText -> Int Source #

O(n) Returns the length of the `ShortText` in characters.

byteLength :: ShortText -> Int Source #

O(1) Returns the length of the `ShortText` in bytes.

null :: ShortText -> Bool Source #

O(1) Test whether the `ShortText` is the empty string.

splitFilePath :: ShortText -> [ShortText] Source #

O(n) Split a `ShortText` representing a file path into its components by separating on the file separator characters for this platform.

head :: ShortText -> Char Source #

O(1) Returns the first UTF-8 codepoint in the `ShortText`. Depending on the string in question, this may or may not be the actual first character in the string due to Unicode non-printable characters.

stripPrefix :: ShortText -> ShortText -> Maybe ShortText Source #

O(n) The `stripPrefix` function takes two `ShortText`s and returns `Just` the remainder of the second iff the first is its prefix, and otherwise Nothing.