basement-0.0.16: Foundation scrap box of array & string

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

Basement.Types.AsciiString

Contents

- Binary conversion

Description

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

Synopsis

- newtype AsciiString = AsciiString {
  - toBytes :: UArray Char7
  }
- newtype MutableAsciiString st = MutableAsciiString (MUArray Char7 st)
- fromBytesUnsafe :: UArray Word8 -> AsciiString
- fromBytes :: UArray Word8 -> Maybe AsciiString

# Documentation

newtype AsciiString Source #

Opaque packed array of characters in the ASCII encoding

Constructors

AsciiString |

Fields

- toBytes :: UArray Char7

#### Instances

Instances details

IsString AsciiString Source # |
Instance details Defined in Basement.Types.AsciiString Methods fromString :: String -> AsciiString Source #
Monoid AsciiString Source # |
Instance details Defined in Basement.Types.AsciiString Methods mempty :: AsciiString Source # mappend :: AsciiString -> AsciiString -> AsciiString Source # mconcat :: [AsciiString] -> AsciiString Source #
Semigroup AsciiString Source # |
Instance details Defined in Basement.Types.AsciiString Methods (<>) :: AsciiString -> AsciiString -> AsciiString Source # sconcat :: NonEmpty AsciiString -> AsciiString Source # stimes :: Integral b => b -> AsciiString -> AsciiString Source #
IsList AsciiString Source # |
Instance details Defined in Basement.Types.AsciiString Associated Types type Item AsciiString Source # Methods fromList :: [Item AsciiString] -> AsciiString Source # fromListN :: Int -> [Item AsciiString] -> AsciiString Source # toList :: AsciiString -> [Item AsciiString] Source #
Show AsciiString Source # |
Instance details Defined in Basement.Types.AsciiString Methods showsPrec :: Int -> AsciiString -> ShowS Source # show :: AsciiString -> String Source # showList :: [AsciiString] -> ShowS Source #
Eq AsciiString Source # |
Instance details Defined in Basement.Types.AsciiString Methods (==) :: AsciiString -> AsciiString -> Bool Source # (/=) :: AsciiString -> AsciiString -> Bool Source #
Ord AsciiString Source # |

Instance details

Defined in Basement.Types.AsciiString

Methods

compare :: AsciiString -> AsciiString -> Ordering Source #

(<) :: AsciiString -> AsciiString -> Bool Source #

(<=) :: AsciiString -> AsciiString -> Bool Source #

(>) :: AsciiString -> AsciiString -> Bool Source #

(>=) :: AsciiString -> AsciiString -> Bool Source #

max :: AsciiString -> AsciiString -> AsciiString Source #

min :: AsciiString -> AsciiString -> AsciiString Source #

From AsciiString String Source # |
Instance details Defined in Basement.From Methods from :: AsciiString -> String Source #
From AsciiString (UArray Word8) Source # |
Instance details Defined in Basement.From Methods from :: AsciiString -> UArray Word8 Source #
type Item AsciiString Source # |
Instance details Defined in Basement.Types.AsciiString type Item AsciiString = Char7

newtype MutableAsciiString st Source #

Constructors

MutableAsciiString (MUArray Char7 st) |

# Binary conversion

fromBytesUnsafe :: UArray Word8 -> AsciiString Source #

Convert a Byte Array representing ASCII data directly to an AsciiString without checking for ASCII validity

If the input contains invalid Char7 value (anything above 0x7f), it will trigger runtime async errors when processing data.

In doubt, use `fromBytes`

fromBytes :: UArray Word8 -> Maybe AsciiString Source #

Convert a Byte Array representing ASCII checking validity.

If the byte array is not valid, then Nothing is returned