ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

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 Source # mappend :: ShortText -> ShortText -> ShortText Source # mconcat :: [ShortText] -> ShortText Source #
Semigroup ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods (<>) :: ShortText -> ShortText -> ShortText Source # sconcat :: NonEmpty ShortText -> ShortText Source # stimes :: Integral b => b -> ShortText -> ShortText Source #
IsString ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods fromString :: String -> ShortText Source #
Show ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods showsPrec :: Int -> ShortText -> ShowS Source # show :: ShortText -> String Source # showList :: [ShortText] -> ShowS Source #
Eq ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods (==) :: ShortText -> ShortText -> Bool Source # (/=) :: ShortText -> ShortText -> Bool Source #
Ord ShortText Source # |

Instance details

Defined in GHC.Data.ShortText

Methods

compare :: ShortText -> ShortText -> Ordering Source #

(<) :: ShortText -> ShortText -> Bool Source #

(<=) :: ShortText -> ShortText -> Bool Source #

(>) :: ShortText -> ShortText -> Bool Source #

(>=) :: ShortText -> ShortText -> Bool Source #

max :: ShortText -> ShortText -> ShortText Source #

min :: ShortText -> ShortText -> ShortText Source #

## 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.