Data.Bytes.Parser.Unsafe

bytesmith-0.3.11.1: Nonresumable byte parser

Safe Haskell | None
Language | Haskell2010

Data.Bytes.Parser.Unsafe

Contents

- Types
- Functions

Description

Everything in this module is unsafe and can lead to nondeterministic output or segfaults if used incorrectly.

Synopsis

- newtype Parser a b (c :: TYPE r) where
  - Parser :: forall (r :: RuntimeRep) a b (c :: TYPE r). {..} -> Parser a b c
- cursor :: Parser e s Int
- cursor# :: Parser e s Int#
- expose :: Parser e s ByteArray
- unconsume :: Int -> Parser e s ()
- jump :: Int -> Parser e s ()
- uneffectful :: (Bytes -> Result e a) -> Parser e s a

# Types

newtype Parser a b (c :: TYPE r) where #

A non-resumable parser.

Constructors

Parser |
Fields :: forall (r :: RuntimeRep) a b (c :: TYPE r). { runParser :: (# ByteArray#, Int#, Int# #) -> ST# b (Result# a c) } -> Parser a b c

#### Instances

Instances details

Monoid e => Alternative (Parser e s :: Type -> Type) # | Combines the error messages using `<>` when both parsers fail.
Instance details Defined in Data.Bytes.Parser.Internal Methods empty :: Parser e s a # (<|>) :: Parser e s a -> Parser e s a -> Parser e s a # some :: Parser e s a -> Parser e s [a] # many :: Parser e s a -> Parser e s [a] #
Applicative (Parser e s :: Type -> Type) # |
Instance details Defined in Data.Bytes.Parser.Internal Methods pure :: a -> Parser e s a # (<*>) :: Parser e s (a -> b) -> Parser e s a -> Parser e s b # liftA2 :: (a -> b -> c) -> Parser e s a -> Parser e s b -> Parser e s c # (*>) :: Parser e s a -> Parser e s b -> Parser e s b # (<*) :: Parser e s a -> Parser e s b -> Parser e s a #
Functor (Parser e s :: Type -> Type) # |
Instance details Defined in Data.Bytes.Parser.Internal Methods fmap :: (a -> b) -> Parser e s a -> Parser e s b # (<$) :: a -> Parser e s b -> Parser e s a #
Monad (Parser e s :: Type -> Type) # |
Instance details Defined in Data.Bytes.Parser.Internal Methods (>>=) :: Parser e s a -> (a -> Parser e s b) -> Parser e s b # (>>) :: Parser e s a -> Parser e s b -> Parser e s b # return :: a -> Parser e s a #

# Functions

cursor :: Parser e s Int #

Get the current offset into the chunk. Using this makes it possible to observe the internal difference between `Bytes` that refer to equivalent slices. Be careful.

cursor# :: Parser e s Int# #

Variant of `cursor` with unboxed result.

expose :: Parser e s ByteArray #

Return the byte array being parsed. This includes bytes that preceed the current offset and may include bytes that go beyond the length. This is somewhat dangerous, so only use this is you know what you're doing.

unconsume :: Int -> Parser e s () #

Move the cursor back by `n` bytes. Precondition: you must have previously consumed at least `n` bytes.

jump :: Int -> Parser e s () #

Set the position to the given index. Precondition: the index must be valid. It should be the result of an earlier call to `cursor`.

uneffectful :: (Bytes -> Result e a) -> Parser e s a #