basement-0.0.4: 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 Source #

Opaque packed array of characters in the ASCII encoding

Constructors

AsciiString |

Fields

- toBytes :: UArray Char7

Instances

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