Cabal-syntax-3.12.1.0: A library for working with .cabal files

Safe Haskell | None
Language | Haskell2010

Distribution.Utils.ShortText

Contents

- `ShortText` type
- Operations
- internal utilities

Description

Compact representation of short `Strings`

This module is designed to be import qualified

    import Distribution.Utils.ShortText (ShortText)
    import qualified Distribution.Utils.ShortText as ShortText

Synopsis

- data ShortText
- toShortText :: String -> ShortText
- fromShortText :: ShortText -> String
- unsafeFromUTF8BS :: ByteString -> ShortText
- null :: ShortText -> Bool
- length :: ShortText -> Int
- decodeStringUtf8 :: [Word8] -> String
- encodeStringUtf8 :: String -> [Word8]

# `ShortText` type

data ShortText Source #

Compact representation of short `Strings`

The data is stored internally as UTF8 in an `ShortByteString` when compiled against `bytestring >= 0.10.4`, and otherwise the fallback is to use plain old non-compat '[Char]'.

Note: This type is for internal uses (such as e.g. `PackageName`) and shall not be exposed in Cabal's API

Since: Cabal-syntax-2.0.0.2

#### Instances

Instances details

Structured ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods structure :: Proxy ShortText -> Structure Source # structureHash' :: Tagged ShortText MD5
Binary ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods put :: ShortText -> Put Source # get :: Get ShortText Source # putList :: [ShortText] -> Put Source #
NFData ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods rnf :: ShortText -> () Source #
Monoid ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods mempty :: ShortText # mappend :: ShortText -> ShortText -> ShortText # mconcat :: [ShortText] -> ShortText #
Semigroup ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods (<>) :: ShortText -> ShortText -> ShortText # sconcat :: NonEmpty ShortText -> ShortText # stimes :: Integral b => b -> ShortText -> ShortText #
Data ShortText Source # |

Instance details

Defined in Distribution.Utils.ShortText

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ShortText -> c ShortText #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ShortText #

toConstr :: ShortText -> Constr #

dataTypeOf :: ShortText -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ShortText) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ShortText) #

gmapT :: (forall b. Data b => b -> b) -> ShortText -> ShortText #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ShortText -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ShortText -> r #

gmapQ :: (forall d. Data d => d -> u) -> ShortText -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ShortText -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ShortText -> m ShortText #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ShortText -> m ShortText #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ShortText -> m ShortText #

IsString ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods fromString :: String -> ShortText #
Generic ShortText Source # |

Instance details

Defined in Distribution.Utils.ShortText

Associated Types

type Rep ShortText |
Instance details Defined in Distribution.Utils.ShortText type Rep ShortText = D1 ('MetaData "ShortText" "Distribution.Utils.ShortText" "Cabal-syntax-3.12.1.0-5c0e" 'True) (C1 ('MetaCons "ST" 'PrefixI 'True) (S1 ('MetaSel ('Just "unST") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString)))

Methods

from :: ShortText -> Rep ShortText x #

to :: Rep ShortText x -> ShortText #

Read ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods readsPrec :: Int -> ReadS ShortText # readList :: ReadS [ShortText] # readPrec :: ReadPrec ShortText # readListPrec :: ReadPrec [ShortText] #
Show ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods showsPrec :: Int -> ShortText -> ShowS # show :: ShortText -> String # showList :: [ShortText] -> ShowS #
Eq ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText Methods (==) :: ShortText -> ShortText -> Bool # (/=) :: ShortText -> ShortText -> Bool #
Ord ShortText Source # |
Instance details Defined in Distribution.Utils.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 #
type Rep ShortText Source # |
Instance details Defined in Distribution.Utils.ShortText type Rep ShortText = D1 ('MetaData "ShortText" "Distribution.Utils.ShortText" "Cabal-syntax-3.12.1.0-5c0e" 'True) (C1 ('MetaCons "ST" 'PrefixI 'True) (S1 ('MetaSel ('Just "unST") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString)))

toShortText :: String -> ShortText Source #

Construct `ShortText` from `String`

fromShortText :: ShortText -> String Source #

Convert `ShortText` to `String`

unsafeFromUTF8BS :: ByteString -> ShortText Source #

Convert from UTF-8 encoded strict `ByteString`.

Since: Cabal-syntax-3.2.0.0

# Operations

null :: ShortText -> Bool Source #

Text whether `ShortText` is empty.

Since: Cabal-syntax-3.2.0.0

length :: ShortText -> Int Source #

O(n). Length in characters. Slow as converts to string.

Since: Cabal-syntax-3.2.0.0

# internal utilities

decodeStringUtf8 :: [Word8] -> String Source #

Decode `String` from UTF8-encoded octets.

Invalid data in the UTF8 stream (this includes code-points `U+D800` through `U+DFFF`) will be decoded as the replacement character (`U+FFFD`).

See also `encodeStringUtf8`

encodeStringUtf8 :: String -> [Word8] Source #

Encode `String` to a list of UTF8-encoded octets

Code-points in the `U+D800`-`U+DFFF` range will be encoded as the replacement character (i.e. `U+FFFD`).

See also `decodeUtf8`