Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- data ShortByteString
- toShort :: ByteString -> ShortByteString
- fromShort :: ShortByteString -> ByteString
- pack :: [Word8] -> ShortByteString
- unpack :: ShortByteString -> [Word8]
- empty :: ShortByteString
- null :: ShortByteString -> Bool
- length :: ShortByteString -> Int
ShortByteString
data ShortByteString #
A compact representation of a Word8
vector.
It has a lower memory overhead than a ByteString
and and does not
contribute to heap fragmentation. It can be converted to or from a
ByteString
(at the cost of copying the string data). It supports very few
other operations.
It is suitable for use as an internal representation for code that needs
to keep many short strings in memory, but it should not be used as an
interchange type. That is, it should not generally be used in public APIs.
The ByteString
type is usually more suitable for use in interfaces; it is
more flexible and it supports a wide range of operations.
Instances
toShort :: ByteString -> ShortByteString #
O(n). Convert a ByteString
into a ShortByteString
.
This makes a copy, so does not retain the input string.
fromShort :: ShortByteString -> ByteString #
O(n). Convert a ShortByteString
into a ByteString
.
pack :: [Word8] -> ShortByteString #
O(n). Convert a list into a ShortByteString
unpack :: ShortByteString -> [Word8] #
O(n). Convert a ShortByteString
into a list.
O(1). The empty ShortByteString
.
null :: ShortByteString -> Bool #
O(1) Test whether a ShortByteString
is empty.
length :: ShortByteString -> Int #
O(1) The length of a ShortByteString
.