GHC.Data.ShortText

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

Safe Haskell | Safe-Inferred
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
  }
- 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

IsString ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods fromString :: String -> 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 #
Show ShortText Source # |
Instance details Defined in GHC.Data.ShortText Methods showsPrec :: Int -> ShortText -> ShowS Source # show :: ShortText -> String Source # showList :: [ShortText] -> ShowS Source #
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 #
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

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.