|
Data.PackedString | Portability | portable | Stability | experimental | Maintainer | libraries@haskell.org |
|
|
|
|
|
Description |
An efficient implementation of strings.
|
|
Synopsis |
|
|
|
|
The PackedString type
|
|
data PackedString |
A space-efficient representation of a String, which supports various
efficient operations. A PackedString contains full Unicode Chars.
| Instances | |
|
|
Converting to and from PackedStrings
|
|
packString :: String -> PackedString |
Convert a String into a PackedString
|
|
unpackPS :: PackedString -> String |
Convert a PackedString into a String
|
|
I/O with PackedStrings
|
|
hPutPS :: Handle -> PackedString -> IO () |
Outputs a PackedString to the specified Handle.
NOTE: the representation of the PackedString in the file is assumed to
be in the ISO-8859-1 encoding. In other words, only the least significant
byte is taken from each character in the PackedString.
|
|
hGetPS :: Handle -> Int -> IO PackedString |
Read a PackedString directly from the specified Handle.
This is far more efficient than reading the characters into a String
and then using packString.
NOTE: as with hPutPS, the string representation in the file is
assumed to be ISO-8859-1.
|
|
List-like manipulation functions
|
|
nilPS :: PackedString |
The nilPS value is the empty string.
|
|
consPS :: Char -> PackedString -> PackedString |
The consPS function prepends the given character to the
given string.
|
|
headPS :: PackedString -> Char |
The headPS function returns the first element of a PackedString or throws an
error if the string is empty.
|
|
tailPS :: PackedString -> PackedString |
The tailPS function returns the tail of a PackedString or throws an error
if the string is empty.
|
|
nullPS :: PackedString -> Bool |
The nullPS function returns True iff the argument is null.
|
|
appendPS :: PackedString -> PackedString -> PackedString |
The appendPS function appends the second string onto the first.
|
|
lengthPS :: PackedString -> Int |
The lengthPS function returns the length of the input list. Analogous to length.
|
|
indexPS :: PackedString -> Int -> Char |
The indexPS function returns the character in the string at the given position.
|
|
mapPS :: (Char -> Char) -> PackedString -> PackedString |
The mapPS function applies a function to each character in the string.
|
|
filterPS :: (Char -> Bool) -> PackedString -> PackedString |
The filterPS function filters out the appropriate substring.
|
|
reversePS :: PackedString -> PackedString |
The reversePS function reverses the string.
|
|
concatPS :: [PackedString] -> PackedString |
The concatPS function concatenates a list of PackedStrings.
|
|
elemPS :: Char -> PackedString -> Bool |
The elemPS function returns True iff the given element is in the string.
|
|
substrPS :: PackedString -> Int -> Int -> PackedString |
The substrPS function takes a PackedString and two indices
and returns the substring of the input string between (and including)
these indices.
|
|
takePS :: Int -> PackedString -> PackedString |
The takePS function takes the first n characters of a PackedString.
|
|
dropPS :: Int -> PackedString -> PackedString |
The dropPS function drops the first n characters of a PackedString.
|
|
splitAtPS :: Int -> PackedString -> (PackedString, PackedString) |
The splitWithPS function splits a PackedString at a given index.
|
|
foldlPS :: (a -> Char -> a) -> a -> PackedString -> a |
The foldlPS function behaves like foldl on PackedStrings.
|
|
foldrPS :: (Char -> a -> a) -> a -> PackedString -> a |
The foldrPS function behaves like foldr on PackedStrings.
|
|
takeWhilePS :: (Char -> Bool) -> PackedString -> PackedString |
The takeWhilePS function is analogous to the takeWhile function.
|
|
dropWhilePS :: (Char -> Bool) -> PackedString -> PackedString |
The dropWhilePS function is analogous to the dropWhile function.
|
|
spanPS :: (Char -> Bool) -> PackedString -> (PackedString, PackedString) |
The spanPS function returns a pair containing the result of
running both takeWhilePS and dropWhilePS.
|
|
breakPS :: (Char -> Bool) -> PackedString -> (PackedString, PackedString) |
The breakPS function breaks a string at the first position which
satisfies the predicate.
|
|
linesPS :: PackedString -> [PackedString] |
The linesPS function splits the input on line-breaks.
|
|
unlinesPS :: [PackedString] -> PackedString |
The unlinesPS function concatenates the input list after
interspersing newlines.
|
|
wordsPS :: PackedString -> [PackedString] |
The wordsPS function is analogous to the words function.
|
|
unwordsPS :: [PackedString] -> PackedString |
The unwordsPS function is analogous to the unwords function.
|
|
splitPS :: Char -> PackedString -> [PackedString] |
The splitPS function splits the input string on each occurrence of the given Char.
|
|
splitWithPS :: (Char -> Bool) -> PackedString -> [PackedString] |
The splitWithPS function takes a character predicate and splits the input string
at each character which satisfies the predicate.
|
|
joinPS :: PackedString -> [PackedString] -> PackedString |
The joinPS function takes a PackedString and a list of PackedStrings
and concatenates the list after interspersing the first argument between
each element of the list.
|
|
Produced by Haddock version 0.7 |