paripari-0.7.0.0: Parser combinators with fast-path and slower fallback for error reporting

Safe HaskellNone
LanguageHaskell2010

Text.PariPari.Internal.Reporter

Synopsis

Documentation

newtype Reporter k a Source #

Parser which is optimised for good error reports. Performance is secondary, since the Reporter is used as a fallback to the Acceptor.

Constructors

Reporter 

Fields

Instances
Chunk k => Parser k (Reporter k) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Chunk k => Monad (Reporter k) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

(>>=) :: Reporter k a -> (a -> Reporter k b) -> Reporter k b #

(>>) :: Reporter k a -> Reporter k b -> Reporter k b #

return :: a -> Reporter k a #

fail :: String -> Reporter k a #

Chunk k => Functor (Reporter k) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

fmap :: (a -> b) -> Reporter k a -> Reporter k b #

(<$) :: a -> Reporter k b -> Reporter k a #

Chunk k => MonadFail (Reporter k) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

fail :: String -> Reporter k a #

Chunk k => Applicative (Reporter k) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

pure :: a -> Reporter k a #

(<*>) :: Reporter k (a -> b) -> Reporter k a -> Reporter k b #

liftA2 :: (a -> b -> c) -> Reporter k a -> Reporter k b -> Reporter k c #

(*>) :: Reporter k a -> Reporter k b -> Reporter k b #

(<*) :: Reporter k a -> Reporter k b -> Reporter k a #

Chunk k => Alternative (Reporter k) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

empty :: Reporter k a #

(<|>) :: Reporter k a -> Reporter k a -> Reporter k a #

some :: Reporter k a -> Reporter k [a] #

many :: Reporter k a -> Reporter k [a] #

Chunk k => MonadPlus (Reporter k) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

mzero :: Reporter k a #

mplus :: Reporter k a -> Reporter k a -> Reporter k a #

Chunk k => IsString (Reporter k k) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

fromString :: String -> Reporter k k #

(Chunk k, Semigroup a) => Semigroup (Reporter k a) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

(<>) :: Reporter k a -> Reporter k a -> Reporter k a #

sconcat :: NonEmpty (Reporter k a) -> Reporter k a #

stimes :: Integral b => b -> Reporter k a -> Reporter k a #

(Chunk k, Semigroup a, Monoid a) => Monoid (Reporter k a) Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

mempty :: Reporter k a #

mappend :: Reporter k a -> Reporter k a -> Reporter k a #

mconcat :: [Reporter k a] -> Reporter k a #

local :: (State -> Env k -> Env k) -> Reporter k a -> Reporter k a Source #

Reader monad, modify environment locally

get :: (Env k -> State -> a) -> Reporter k a Source #

Reader monad, get something from the environment

raiseError :: Env k -> State -> (State -> b) -> Error -> b Source #

mergeErrorState :: Env k -> State -> State -> State Source #

Merge errors of two states, used when backtracking

data Report Source #

Instances
Eq Report Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Methods

(==) :: Report -> Report -> Bool #

(/=) :: Report -> Report -> Bool #

Show Report Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Generic Report Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Associated Types

type Rep Report :: Type -> Type #

Methods

from :: Report -> Rep Report x #

to :: Rep Report x -> Report #

type Rep Report Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

type Rep Report = D1 (MetaData "Report" "Text.PariPari.Internal.Reporter" "paripari-0.7.0.0-IvEurrnvmehFR9IQGtFHTg" False) (C1 (MetaCons "Report" PrefixI True) ((S1 (MetaSel (Just "_reportFile") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 FilePath) :*: S1 (MetaSel (Just "_reportErrors") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [ErrorContext])) :*: (S1 (MetaSel (Just "_reportLine") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Just "_reportCol") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int))))

runReporter :: Chunk k => Reporter k a -> FilePath -> k -> (Maybe a, [Report]) Source #

Run Reporter on the given chunk, returning the result if successful and reports from error recoveries. In the case of an error, Nothing is returned and the Report list is non-empty.

data ErrorContext Source #

Constructors

ErrorContext 

Fields

Instances
Eq ErrorContext Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Show ErrorContext Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Generic ErrorContext Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Associated Types

type Rep ErrorContext :: Type -> Type #

type Rep ErrorContext Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

type Rep ErrorContext = D1 (MetaData "ErrorContext" "Text.PariPari.Internal.Reporter" "paripari-0.7.0.0-IvEurrnvmehFR9IQGtFHTg" False) (C1 (MetaCons "ErrorContext" PrefixI True) (S1 (MetaSel (Just "_ecErrors") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [Error]) :*: S1 (MetaSel (Just "_ecContext") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [String])))

showReport :: Report -> String Source #

Pretty string representation of Report.

showErrors :: [ErrorContext] -> String Source #

Pretty string representation of '[ErrorContext]'.

data ReportOptions Source #

Instances
Eq ReportOptions Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Show ReportOptions Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Generic ReportOptions Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

Associated Types

type Rep ReportOptions :: Type -> Type #

type Rep ReportOptions Source # 
Instance details

Defined in Text.PariPari.Internal.Reporter

type Rep ReportOptions = D1 (MetaData "ReportOptions" "Text.PariPari.Internal.Reporter" "paripari-0.7.0.0-IvEurrnvmehFR9IQGtFHTg" False) (C1 (MetaCons "ReportOptions" PrefixI True) (S1 (MetaSel (Just "_optMaxContexts") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int) :*: (S1 (MetaSel (Just "_optMaxErrorsPerContext") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Just "_optMaxLabelsPerContext") SourceUnpack SourceStrict DecidedStrict) (Rec0 Int))))