megaparsec-utils-0.1.1.3: Parsers and utilities for the Megaparsec library.
Copyright(c) drlkf 2024
LicenseGPL-3
Maintainerdrlkf@drlkf.net
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Text.Megaparsec.Utils

Description

Generic utilities and common parsers.

Synopsis

Scalar parsers

boolParser :: Ord e => Parsec e String Bool Source #

Parse a case-insensitive human-readable boolean, including C-style numbers, English yes-no and on / off.

numParser :: (Ord e, Num a, Read a) => Parsec e String a Source #

Parse an integer, without any space between minus sign and digits.

posDecNumParser :: (Ord e, Read a) => Parsec e String a Source #

Parse a positive number, with or without decimals prefixed by a ..

posNumParser :: (Ord e, Read a) => Parsec e String a Source #

Parse a positive integer.

uuidParser :: Ord e => Parsec e String UUID Source #

Parse a RFC4122-compliant UUID.

Combinators

commaSeparated :: Ord e => Parsec e String a -> Parsec e String (NonEmpty a) Source #

Parse a comma-separated list of items.

occurrence :: Ord e => Parsec e String a -> Parsec e String a Source #

Parse any occurrence of a given parser. Consumes any input before occurrence.

occurrences :: Ord e => Parsec e String a -> Parsec e String [a] Source #

Parse all occurrences of a given parser.

Compatibility utilities

boundedEnumShowParser :: forall a e. (Ord e, Bounded a, Enum a, Show a) => Parsec e String a Source #

Parse a Bounded Enum type that has a Show instance, trying all possibilities, case-insensitive, in the Enum order.

parsecToReadsPrec :: Parsec e String a -> ReadS a Source #

Convert a Parsec parser into a ReadS parser. Useful for defining Read instances with Megaparsec.

parsecToJSONParser Source #

Arguments

:: ShowErrorComponent e 
=> String

Parser name.

-> Parsec e String a

Parser.

-> Value 
-> Parser a 

Convert a Parsec parser into a Parser suited for FromJSON instances.