megaparsec-6.5.0: Monadic parser combinators

Copyright© 2015–2018 Megaparsec contributors
LicenseFreeBSD
MaintainerMark Karpov <markkarpov92@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Text.Megaparsec.Error.Builder

Contents

Description

A set of helpers that should make construction of ParseErrors more concise. This is primarily useful in test suites and for debugging, you most certainly don't need it for normal usage.

Since: megaparsec-6.0.0

Synopsis

Top-level helpers

err Source #

Arguments

:: NonEmpty SourcePos

ParseError position

-> ET t

Error components

-> ParseError t e

Resulting ParseError

Assemble a ParseError from source position and ET t value. To create source position, two helpers are available: posI and posN. ET t is a monoid and can be assembled by combining primitives provided by this module, see below.

errFancy Source #

Arguments

:: NonEmpty SourcePos

ParseError position

-> EF e

Error components

-> ParseError t e

Resulting ParseError

Like err, but constructs a “fancy” ParseError.

Error position

posI :: NonEmpty SourcePos Source #

Initial source position with empty file name.

posN :: forall s. Stream s => Int -> s -> NonEmpty SourcePos Source #

posN n s returns source position achieved by applying advanceN method corresponding to the type of stream s.

Error components

utok :: Ord t => t -> ET t Source #

Construct an “unexpected token” error component.

utoks :: Ord t => [t] -> ET t Source #

Construct an “unexpected tokens” error component. Empty string produces EndOfInput.

ulabel :: Ord t => String -> ET t Source #

Construct an “unexpected label” error component. Do not use with empty strings (for empty strings it's bottom).

ueof :: Ord t => ET t Source #

Construct an “unexpected end of input” error component.

etok :: Ord t => t -> ET t Source #

Construct an “expected token” error component.

etoks :: Ord t => [t] -> ET t Source #

Construct an “expected tokens” error component. Empty string produces EndOfInput.

elabel :: Ord t => String -> ET t Source #

Construct an “expected label” error component. Do not use with empty strings.

eeof :: Ord t => ET t Source #

Construct an “expected end of input” error component.

fancy :: ErrorFancy e -> EF e Source #

Construct a custom error component.

Data types

data ET t Source #

Auxiliary type for construction of trivial parse errors.

Instances
Eq t => Eq (ET t) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

(==) :: ET t -> ET t -> Bool #

(/=) :: ET t -> ET t -> Bool #

(Data t, Ord t) => Data (ET t) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ET t -> c (ET t) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ET t) #

toConstr :: ET t -> Constr #

dataTypeOf :: ET t -> DataType #

dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (ET t)) #

dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (ET t)) #

gmapT :: (forall b. Data b => b -> b) -> ET t -> ET t #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ET t -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ET t -> r #

gmapQ :: (forall d. Data d => d -> u) -> ET t -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ET t -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ET t -> m (ET t) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ET t -> m (ET t) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ET t -> m (ET t) #

Ord t => Ord (ET t) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

compare :: ET t -> ET t -> Ordering #

(<) :: ET t -> ET t -> Bool #

(<=) :: ET t -> ET t -> Bool #

(>) :: ET t -> ET t -> Bool #

(>=) :: ET t -> ET t -> Bool #

max :: ET t -> ET t -> ET t #

min :: ET t -> ET t -> ET t #

Generic (ET t) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Associated Types

type Rep (ET t) :: * -> * #

Methods

from :: ET t -> Rep (ET t) x #

to :: Rep (ET t) x -> ET t #

Ord t => Semigroup (ET t) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

(<>) :: ET t -> ET t -> ET t #

sconcat :: NonEmpty (ET t) -> ET t #

stimes :: Integral b => b -> ET t -> ET t #

Ord t => Monoid (ET t) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

mempty :: ET t #

mappend :: ET t -> ET t -> ET t #

mconcat :: [ET t] -> ET t #

type Rep (ET t) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

type Rep (ET t) = D1 (MetaData "ET" "Text.Megaparsec.Error.Builder" "megaparsec-6.5.0-4VKBtSFJhna3iLscGKIZAP" False) (C1 (MetaCons "ET" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (ErrorItem t))) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Set (ErrorItem t)))))

data EF e Source #

Auxiliary type for construction of fancy parse errors.

Instances
Eq e => Eq (EF e) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

(==) :: EF e -> EF e -> Bool #

(/=) :: EF e -> EF e -> Bool #

(Data e, Ord e) => Data (EF e) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> EF e -> c (EF e) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (EF e) #

toConstr :: EF e -> Constr #

dataTypeOf :: EF e -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (EF e)) #

dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (EF e)) #

gmapT :: (forall b. Data b => b -> b) -> EF e -> EF e #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EF e -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EF e -> r #

gmapQ :: (forall d. Data d => d -> u) -> EF e -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> EF e -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> EF e -> m (EF e) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> EF e -> m (EF e) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> EF e -> m (EF e) #

Ord e => Ord (EF e) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

compare :: EF e -> EF e -> Ordering #

(<) :: EF e -> EF e -> Bool #

(<=) :: EF e -> EF e -> Bool #

(>) :: EF e -> EF e -> Bool #

(>=) :: EF e -> EF e -> Bool #

max :: EF e -> EF e -> EF e #

min :: EF e -> EF e -> EF e #

Generic (EF e) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Associated Types

type Rep (EF e) :: * -> * #

Methods

from :: EF e -> Rep (EF e) x #

to :: Rep (EF e) x -> EF e #

Ord e => Semigroup (EF e) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

(<>) :: EF e -> EF e -> EF e #

sconcat :: NonEmpty (EF e) -> EF e #

stimes :: Integral b => b -> EF e -> EF e #

Ord e => Monoid (EF e) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

Methods

mempty :: EF e #

mappend :: EF e -> EF e -> EF e #

mconcat :: [EF e] -> EF e #

type Rep (EF e) Source # 
Instance details

Defined in Text.Megaparsec.Error.Builder

type Rep (EF e) = D1 (MetaData "EF" "Text.Megaparsec.Error.Builder" "megaparsec-6.5.0-4VKBtSFJhna3iLscGKIZAP" False) (C1 (MetaCons "EF" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Set (ErrorFancy e)))))