foundation-0.0.3: Alternative prelude with batteries and no dependencies

License | BSD-style
Maintainer | Haskell Foundation
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Foundation.String.ASCII

Contents

- Binary conversion
- Legacy utility

Description

A AsciiString type backed by a `ASCII` encoded byte array and all the necessary functions to manipulate the string.

The recommended type is `AsciiString` from `UTF8`

Synopsis

- data AsciiString
- create :: PrimMonad prim => Int -> (MutableAsciiString (PrimState prim) -> prim Int) -> prim AsciiString
- replicate :: Int -> CUChar -> AsciiString
- fromBytesUnsafe :: UArray CUChar -> AsciiString
- toBytes :: AsciiString -> UArray CUChar
- copy :: AsciiString -> AsciiString
- lines :: AsciiString -> [AsciiString]
- words :: AsciiString -> [AsciiString]

# Documentation

data AsciiString #

Opaque packed array of characters in the ASCII encoding

Instances

IsList AsciiString # |
Associated Types type Item AsciiString :: * # Methods fromList :: [Item AsciiString] -> AsciiString # fromListN :: Int -> [Item AsciiString] -> AsciiString # toList :: AsciiString -> [Item AsciiString] #
Eq AsciiString # |
Methods (==) :: AsciiString -> AsciiString -> Bool # (/=) :: AsciiString -> AsciiString -> Bool #
Ord AsciiString # |
Methods compare :: AsciiString -> AsciiString -> Ordering # (<) :: AsciiString -> AsciiString -> Bool # (<=) :: AsciiString -> AsciiString -> Bool # (>) :: AsciiString -> AsciiString -> Bool # (>=) :: AsciiString -> AsciiString -> Bool # max :: AsciiString -> AsciiString -> AsciiString # min :: AsciiString -> AsciiString -> AsciiString #
Show AsciiString # |
Methods showsPrec :: Int -> AsciiString -> ShowS # show :: AsciiString -> String # showList :: [AsciiString] -> ShowS #
IsString AsciiString # |
Methods fromString :: String -> AsciiString #
Monoid AsciiString # |
Methods mempty :: AsciiString # mappend :: AsciiString -> AsciiString -> AsciiString # mconcat :: [AsciiString] -> AsciiString #
InnerFunctor AsciiString # |
Methods imap :: (Element AsciiString -> Element AsciiString) -> AsciiString -> AsciiString #
Collection AsciiString # |
Methods null :: AsciiString -> Bool # length :: AsciiString -> Int # elem :: (Eq a, (* ~ a) (Element AsciiString)) => Element AsciiString -> AsciiString -> Bool # notElem :: (Eq a, (* ~ a) (Element AsciiString)) => Element AsciiString -> AsciiString -> Bool # maximum :: (Ord a, (* ~ a) (Element AsciiString)) => NonEmpty AsciiString -> Element AsciiString # minimum :: (Ord a, (* ~ a) (Element AsciiString)) => NonEmpty AsciiString -> Element AsciiString #
Sequential AsciiString # |
Methods take :: Int -> AsciiString -> AsciiString # revTake :: Int -> AsciiString -> AsciiString # drop :: Int -> AsciiString -> AsciiString # revDrop :: Int -> AsciiString -> AsciiString # splitAt :: Int -> AsciiString -> (AsciiString, AsciiString) # revSplitAt :: Int -> AsciiString -> (AsciiString, AsciiString) # splitOn :: (Element AsciiString -> Bool) -> AsciiString -> [AsciiString] # break :: (Element AsciiString -> Bool) -> AsciiString -> (AsciiString, AsciiString) # breakElem :: Element AsciiString -> AsciiString -> (AsciiString, AsciiString) # intersperse :: Element AsciiString -> AsciiString -> AsciiString # intercalate :: Element AsciiString -> AsciiString -> Element AsciiString # span :: (Element AsciiString -> Bool) -> AsciiString -> (AsciiString, AsciiString) # filter :: (Element AsciiString -> Bool) -> AsciiString -> AsciiString # partition :: (Element AsciiString -> Bool) -> AsciiString -> (AsciiString, AsciiString) # reverse :: AsciiString -> AsciiString # uncons :: AsciiString -> Maybe (Element AsciiString, AsciiString) # unsnoc :: AsciiString -> Maybe (AsciiString, Element AsciiString) # snoc :: AsciiString -> Element AsciiString -> AsciiString # cons :: Element AsciiString -> AsciiString -> AsciiString # find :: (Element AsciiString -> Bool) -> AsciiString -> Maybe (Element AsciiString) # sortBy :: (Element AsciiString -> Element AsciiString -> Ordering) -> AsciiString -> AsciiString # singleton :: Element AsciiString -> AsciiString # head :: NonEmpty AsciiString -> Element AsciiString # last :: NonEmpty AsciiString -> Element AsciiString # tail :: NonEmpty AsciiString -> AsciiString # init :: NonEmpty AsciiString -> AsciiString # isPrefixOf :: AsciiString -> AsciiString -> Bool # isSuffixOf :: AsciiString -> AsciiString -> Bool #
Zippable AsciiString # |
Methods zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element AsciiString) -> a -> b -> AsciiString # zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element AsciiString) -> a -> b -> c -> AsciiString # zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d) => (Element a -> Element b -> Element c -> Element d -> Element AsciiString) -> a -> b -> c -> d -> AsciiString # zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element AsciiString) -> a -> b -> c -> d -> e -> AsciiString # zipWith6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element f -> Element AsciiString) -> a -> b -> c -> d -> e -> f -> AsciiString # zipWith7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element f -> Element g -> Element AsciiString) -> a -> b -> c -> d -> e -> f -> g -> AsciiString #
type Item AsciiString # |
type Item AsciiString = CUChar
type Element AsciiString # |
type Element AsciiString = CUChar

create :: PrimMonad prim => Int -> (MutableAsciiString (PrimState prim) -> prim Int) -> prim AsciiString #

replicate :: Int -> CUChar -> AsciiString #

# Binary conversion

fromBytesUnsafe :: UArray CUChar -> AsciiString #

Convert a Byte Array representing UTF8 data directly to a string without checking for UTF8 validity

If the input contains invalid sequences, it will trigger runtime async errors when processing data.

In doubt, use `fromBytes`

toBytes :: AsciiString -> UArray CUChar #

copy :: AsciiString -> AsciiString #

Copy the AsciiString

# Legacy utility

lines :: AsciiString -> [AsciiString] #

words :: AsciiString -> [AsciiString] #