Copyright | (c) Galois Inc 2019-2020 |
---|---|
License | BSD3 |
Maintainer | Rob Dockins <rdockins@galois.com> |
Stability | provisional |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data Word16String
- fromLEByteString :: ByteString -> Word16String
- toLEByteString :: Word16String -> ByteString
- empty :: Word16String
- singleton :: Word16 -> Word16String
- null :: Word16String -> Bool
- index :: Word16String -> Int -> Word16
- drop :: Int -> Word16String -> Word16String
- take :: Int -> Word16String -> Word16String
- append :: Word16String -> Word16String -> Word16String
- length :: Word16String -> Int
- foldl' :: (a -> Word16 -> a) -> a -> Word16String -> a
- findSubstring :: Word16String -> Word16String -> Maybe Int
- isInfixOf :: Word16String -> Word16String -> Bool
- isPrefixOf :: Word16String -> Word16String -> Bool
- isSuffixOf :: Word16String -> Word16String -> Bool
Documentation
data Word16String Source #
A string of Word16 values, encoded as a bytestring in little endian (LE) order.
We maintain the invariant that Word16Strings are represented by an even number of bytes.
Instances
fromLEByteString :: ByteString -> Word16String Source #
Generate a Word16String
from a bytestring
where the 16bit words are encoded as two bytes
in little-endian order.
PRECONDITION: the input bytestring must have a length which is a multiple of 2.
toLEByteString :: Word16String -> ByteString Source #
Return the underlying little endian bytestring.
empty :: Word16String Source #
Return the empty string
singleton :: Word16 -> Word16String Source #
Compute the string containing just the given character
null :: Word16String -> Bool Source #
Test if the given string is empty
index :: Word16String -> Int -> Word16 Source #
Retrive the n
th character of the string.
Out of bounds accesses will cause an error.
drop :: Int -> Word16String -> Word16String Source #
take :: Int -> Word16String -> Word16String Source #
append :: Word16String -> Word16String -> Word16String Source #
length :: Word16String -> Int Source #
foldl' :: (a -> Word16 -> a) -> a -> Word16String -> a Source #
findSubstring :: Word16String -> Word16String -> Maybe Int Source #
Find the first index (if it exists) where the first string appears as a substring in the second
isInfixOf :: Word16String -> Word16String -> Bool Source #
Returns true if the first string appears somewhere in the second string.
isPrefixOf :: Word16String -> Word16String -> Bool Source #
isSuffixOf :: Word16String -> Word16String -> Bool Source #