toml-parser-1.1.0.0: TOML 1.0.0 parser
Copyright(c) Eric Mertens 2023
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Toml.FromValue.Matcher

Description

This type helps to build up computations that can validate a TOML value and compute some application-specific representation.

It supports warning messages which can be used to deprecate old configuration options and to detect unused table keys.

It supports tracking multiple error messages when you have more than one decoding option and all of them have failed.

Synopsis

Documentation

data Matcher a Source #

Computations that result in a Result and which track a list of nested contexts to assist in generating warnings and error messages.

Use withScope to run a Matcher in a new, nested scope.

Instances

Instances details
MonadFail Matcher Source #

Fail with an error message annotated to the current location.

Instance details

Defined in Toml.FromValue.Matcher

Methods

fail :: String -> Matcher a #

Alternative Matcher Source # 
Instance details

Defined in Toml.FromValue.Matcher

Methods

empty :: Matcher a #

(<|>) :: Matcher a -> Matcher a -> Matcher a #

some :: Matcher a -> Matcher [a] #

many :: Matcher a -> Matcher [a] #

Applicative Matcher Source # 
Instance details

Defined in Toml.FromValue.Matcher

Methods

pure :: a -> Matcher a #

(<*>) :: Matcher (a -> b) -> Matcher a -> Matcher b #

liftA2 :: (a -> b -> c) -> Matcher a -> Matcher b -> Matcher c #

(*>) :: Matcher a -> Matcher b -> Matcher b #

(<*) :: Matcher a -> Matcher b -> Matcher a #

Functor Matcher Source # 
Instance details

Defined in Toml.FromValue.Matcher

Methods

fmap :: (a -> b) -> Matcher a -> Matcher b #

(<$) :: a -> Matcher b -> Matcher a #

Monad Matcher Source # 
Instance details

Defined in Toml.FromValue.Matcher

Methods

(>>=) :: Matcher a -> (a -> Matcher b) -> Matcher b #

(>>) :: Matcher a -> Matcher b -> Matcher b #

return :: a -> Matcher a #

MonadPlus Matcher Source # 
Instance details

Defined in Toml.FromValue.Matcher

Methods

mzero :: Matcher a #

mplus :: Matcher a -> Matcher a -> Matcher a #

data Result a Source #

Computation outcome with error and warning messages. Multiple error messages can occur when multiple alternatives all fail. Resolving any one of the error messages could allow the computation to succeed.

Constructors

Failure [String] 
Success [String] a 

Instances

Instances details
Read a => Read (Result a) Source # 
Instance details

Defined in Toml.FromValue.Matcher

Show a => Show (Result a) Source # 
Instance details

Defined in Toml.FromValue.Matcher

Methods

showsPrec :: Int -> Result a -> ShowS #

show :: Result a -> String #

showList :: [Result a] -> ShowS #

Eq a => Eq (Result a) Source # 
Instance details

Defined in Toml.FromValue.Matcher

Methods

(==) :: Result a -> Result a -> Bool #

(/=) :: Result a -> Result a -> Bool #

Ord a => Ord (Result a) Source # 
Instance details

Defined in Toml.FromValue.Matcher

Methods

compare :: Result a -> Result a -> Ordering #

(<) :: Result a -> Result a -> Bool #

(<=) :: Result a -> Result a -> Bool #

(>) :: Result a -> Result a -> Bool #

(>=) :: Result a -> Result a -> Bool #

max :: Result a -> Result a -> Result a #

min :: Result a -> Result a -> Result a #

runMatcher :: Matcher a -> Result a Source #

Run a Matcher with an empty scope.

withScope :: String -> Matcher a -> Matcher a Source #

Run a Matcher with a locally extended scope.

getScope :: Matcher [String] Source #

Get the current list of scopes.

warning :: String -> Matcher () Source #

Emit a warning mentioning the current scope.