Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 {}
- 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
A ShortText
is a modified UTF-8 encoded string meant for short strings like
file paths, module descriptions, etc.
Instances
Eq ShortText Source # | |
Ord ShortText Source # | |
Defined in GHC.Data.ShortText | |
Show ShortText Source # | |
IsString ShortText Source # | |
Defined in GHC.Data.ShortText fromString :: String -> ShortText # | |
Semigroup ShortText Source # | |
Monoid ShortText Source # | |
Binary ShortText Source # | |
NFData ShortText Source # | |
Defined in GHC.Data.ShortText |
Conversion to and from String
Operations
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.