ghc-boot-9.6.0.20230302: Shared functionality between GHC and its boot libraries
Safe HaskellSafe-Inferred
LanguageHaskell2010

GHC.Data.ShortText

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

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 

Instances

Instances details
IsString ShortText Source # 
Instance details

Defined in GHC.Data.ShortText

Monoid ShortText Source # 
Instance details

Defined in GHC.Data.ShortText

Semigroup ShortText Source # 
Instance details

Defined in GHC.Data.ShortText

Show ShortText Source # 
Instance details

Defined in GHC.Data.ShortText

Binary ShortText Source # 
Instance details

Defined in GHC.Data.ShortText

NFData ShortText Source # 
Instance details

Defined in GHC.Data.ShortText

Methods

rnf :: ShortText -> () Source #

Eq ShortText Source # 
Instance details

Defined in GHC.Data.ShortText

Ord ShortText Source # 
Instance details

Defined in GHC.Data.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 ShortTexts and returns Just the remainder of the second iff the first is its prefix, and otherwise Nothing.