Basement.Types.AsciiString

basement-0.0.16: Foundation scrap box of array & string

License | BSD-style
Maintainer | Haskell Foundation
Stability | experimental
Portability | portable
Safe Haskell | None
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 #

Opaque packed array of characters in the ASCII encoding

Constructors

AsciiString |
Fields toBytes :: UArray Char7

#### Instances

Instances details

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

newtype MutableAsciiString st #

Constructors

MutableAsciiString (MUArray Char7 st) |

# Binary conversion

fromBytesUnsafe :: UArray Word8 -> AsciiString #

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 #

Convert a Byte Array representing ASCII checking validity.

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