HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulememory-0.18.0Haskell2010

Data.ByteArray.Parse

A very simple bytearray parser related to Parsec and Attoparsec

Simple example:

> parse ((,,) <$> take 2 <*> byte 0x20 <*> (bytes "abc" *> anyByte)) "xx abctest"
ParseOK "est" ("xx", 116)
  • 2 types
  • 13 values
  • Packagememory-0.18.0
  • Exports15
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceParse.hs
newtypenewtype Parser byteArray a
#

Simple ByteString parser structure

Instances6Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus
  • Monad (Parser byteArray)Defined in memory-0.18.0 · Data.ByteArray.Parse
  • Functor (Parser byteArray)Defined in memory-0.18.0 · Data.ByteArray.Parse
  • MonadFail (Parser byteArray)Defined in memory-0.18.0 · Data.ByteArray.Parse
  • Applicative (Parser byteArray)Defined in memory-0.18.0 · Data.ByteArray.Parse
  • Alternative (Parser byteArray)Defined in memory-0.18.0 · Data.ByteArray.Parse
  • MonadPlus (Parser byteArray)Defined in memory-0.18.0 · Data.ByteArray.Parse
datadata Result byteArray a
#

Simple parsing result, that represent respectively:

  • failure: with the error message

  • continuation: that need for more input data

  • success: the remaining unparsed data and the parser value

Constructors

Instances1Show

run the Parser

2 declarations
valueparseFeed
  1. :: (ByteArrayAccess byteArray, Monad m)
  2. => m (Maybe byteArray)
  3. -> Parser byteArray a
  4. -> byteArray
  5. -> m (Result byteArray a)
#

Run a parser on an @initial byteArray.

If the Parser need more data than available, the @feeder function is automatically called and fed to the More continuation.

Parser methods

11 declarations
valuebyte :: ByteArray byteArray => Word8 -> Parser byteArray ()
#

Parse a specific byte at current position

if the byte is different than the expected on, this parser will raise a failure.

valuebytes :: (Show ba, Eq ba, ByteArray ba) => ba -> Parser ba ()
#

Parse a sequence of bytes from current position

if the following bytes don't match the expected bytestring completely, the parser will raise a failure

valuetake :: ByteArray byteArray => Int -> Parser byteArray byteArray
#

Take @n bytes from the current position in the stream

valuetakeAll :: ByteArray byteArray => Parser byteArray byteArray
#

Take the remaining bytes from the current position in the stream

valueskip :: ByteArray byteArray => Int -> Parser byteArray ()
#

Skip @n bytes from the current position in the stream

valueskipAll :: ByteArray byteArray => Parser byteArray ()
#

Skip all the remaining bytes from the current position in the stream