HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleram-0.22.1Haskell2010

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)
Contents
  1. run the Parser
  2. Parser methods
Synopsis
  • Packageram-0.22.1
  • Exports15
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceParse.hs
newtypenewtype Parser byteArray a

Simple ByteString parser structure

Instances6Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus
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

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

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