trifecta-2.1: A modern parser combinator library with convenient diagnostics

Text.Trifecta.Result

Contents

Description

Results and Parse Errors

Synopsis

# Parse Results

data Result a Source #

The result of parsing. Either we succeeded or something went wrong.

Constructors

 Success a Failure ErrInfo
Instances
 Source # Instance detailsDefined in Text.Trifecta.Result Methods(>>=) :: Result a -> (a -> Result b) -> Result b #(>>) :: Result a -> Result b -> Result b #return :: a -> Result a #fail :: String -> Result a # Source # Instance detailsDefined in Text.Trifecta.Result Methodsfmap :: (a -> b) -> Result a -> Result b #(<\$) :: a -> Result b -> Result a # Source # Instance detailsDefined in Text.Trifecta.Result Methodspure :: a -> Result a #(<*>) :: Result (a -> b) -> Result a -> Result b #liftA2 :: (a -> b -> c) -> Result a -> Result b -> Result c #(*>) :: Result a -> Result b -> Result b #(<*) :: Result a -> Result b -> Result a # Source # Instance detailsDefined in Text.Trifecta.Result Methodsfold :: Monoid m => Result m -> m #foldMap :: Monoid m => (a -> m) -> Result a -> m #foldr :: (a -> b -> b) -> b -> Result a -> b #foldr' :: (a -> b -> b) -> b -> Result a -> b #foldl :: (b -> a -> b) -> b -> Result a -> b #foldl' :: (b -> a -> b) -> b -> Result a -> b #foldr1 :: (a -> a -> a) -> Result a -> a #foldl1 :: (a -> a -> a) -> Result a -> a #toList :: Result a -> [a] #null :: Result a -> Bool #length :: Result a -> Int #elem :: Eq a => a -> Result a -> Bool #maximum :: Ord a => Result a -> a #minimum :: Ord a => Result a -> a #sum :: Num a => Result a -> a #product :: Num a => Result a -> a # Source # Instance detailsDefined in Text.Trifecta.Result Methodstraverse :: Applicative f => (a -> f b) -> Result a -> f (Result b) #sequenceA :: Applicative f => Result (f a) -> f (Result a) #mapM :: Monad m => (a -> m b) -> Result a -> m (Result b) #sequence :: Monad m => Result (m a) -> m (Result a) # Source # Instance detailsDefined in Text.Trifecta.Result Methodsempty :: Result a #(<|>) :: Result a -> Result a -> Result a #some :: Result a -> Result [a] #many :: Result a -> Result [a] # Show a => Show (Result a) Source # Instance detailsDefined in Text.Trifecta.Result MethodsshowsPrec :: Int -> Result a -> ShowS #show :: Result a -> String #showList :: [Result a] -> ShowS # AsResult (Result a) (Result b) a b Source # Instance detailsDefined in Text.Trifecta.Result Methods_Result :: Prism (Result a) (Result b) (Result a) (Result b) Source #

class AsResult s t a b | s -> a, t -> b, s b -> t, t a -> s where Source #

A Prism that lets you embed or retrieve a Result in a potentially larger type.

Methods

_Result :: Prism s t (Result a) (Result b) Source #

Instances
 AsResult (Result a) (Result b) a b Source # Instance detailsDefined in Text.Trifecta.Result Methods_Result :: Prism (Result a) (Result b) (Result a) (Result b) Source #

foldResult :: (ErrInfo -> b) -> (a -> b) -> Result a -> b Source #

Fold over a Result

_Success :: AsResult s t a b => Prism s t a b Source #

The Prism for the Success constructor of Result

_Failure :: AsResult s s a a => Prism' s ErrInfo Source #

The Prism for the Failure constructor of Result

# Parsing Errors

data Err Source #

This is used to report an error. What went wrong, some supplemental docs and a set of things expected at the current location. This does not, however, include the actual location.

Constructors

 Err Fields_reason :: Maybe (Doc AnsiStyle) _footnotes :: [Doc AnsiStyle] _expected :: Set String _finalDeltas :: [Delta]
Instances
 Source # Instance detailsDefined in Text.Trifecta.Result Methods(<>) :: Err -> Err -> Err #stimes :: Integral b => b -> Err -> Err # Source # Instance detailsDefined in Text.Trifecta.Result Methodsmappend :: Err -> Err -> Err #mconcat :: [Err] -> Err # Source # Instance detailsDefined in Text.Trifecta.Result Methods

class HasErr c where Source #

Minimal complete definition

err

Methods

Instances
 Source # Instance detailsDefined in Text.Trifecta.Result Methods

class Errable m where Source #

Methods

raiseErr :: Err -> m a Source #

Instances
 Source # Instance detailsDefined in Text.Trifecta.Parser Methods

data ErrInfo Source #

Constructors

 ErrInfo Fields_errDoc :: Doc AnsiStyle _errDeltas :: [Delta]
Instances
 Source # Instance detailsDefined in Text.Trifecta.Result MethodsshowList :: [ErrInfo] -> ShowS # Source # Instance detailsDefined in Text.Trifecta.Result Methodsstimes :: Integral b => b -> ErrInfo -> ErrInfo # Source # Instance detailsDefined in Text.Trifecta.Result Methodsmconcat :: [ErrInfo] -> ErrInfo #

Convert a Rendering of auxiliary information and an Err into a 'Doc AnsiStyle', ready to be prettyprinted to the user.

Generate a simple Err word-wrapping the supplied message.