toml-parser-1.3.1.2: 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.

Use prettyMatchMessage for an easy way to make human readable strings from matcher outputs.

Synopsis

Types

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 e 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.

Since: 1.3.0.0

Constructors

Failure [e]

error messages

Success [e] a

warning messages and result

Instances

Instances details
(Read e, Read a) => Read (Result e a) Source #

Default instance

Instance details

Defined in Toml.FromValue.Matcher

(Show e, Show a) => Show (Result e a) Source #

Default instance

Instance details

Defined in Toml.FromValue.Matcher

Methods

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

show :: Result e a -> String #

showList :: [Result e a] -> ShowS #

(Eq e, Eq a) => Eq (Result e a) Source #

Default instance

Instance details

Defined in Toml.FromValue.Matcher

Methods

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

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

(Ord e, Ord a) => Ord (Result e a) Source #

Default instance

Instance details

Defined in Toml.FromValue.Matcher

Methods

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

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

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

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

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

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

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

data MatchMessage Source #

A message emitted while matching a TOML value. The message is paired with the path to the value that was in focus when the message was generated. These message get used for both warnings and errors.

Since: 1.3.0.0

Constructors

MatchMessage 

Fields

Operations

runMatcher :: Matcher a -> Result MatchMessage a Source #

Run a Matcher with an empty scope.

Since: 1.3.0.0

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

Run a Matcher with a locally extended scope.

Since: 1.3.0.0

getScope :: Matcher [Scope] Source #

Get the current list of scopes.

Since: 1.3.0.0

warning :: String -> Matcher () Source #

Emit a warning mentioning the current scope.

Scope helpers

data Scope Source #

Scopes for TOML message.

Since: 1.3.0.0

Constructors

ScopeIndex Int

zero-based array index

ScopeKey String

key in a table

Instances

Instances details
Read Scope Source #

Default instance

Instance details

Defined in Toml.FromValue.Matcher

Show Scope Source #

Default instance

Instance details

Defined in Toml.FromValue.Matcher

Methods

showsPrec :: Int -> Scope -> ShowS #

show :: Scope -> String #

showList :: [Scope] -> ShowS #

Eq Scope Source #

Default instance

Instance details

Defined in Toml.FromValue.Matcher

Methods

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

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

Ord Scope Source #

Default instance

Instance details

Defined in Toml.FromValue.Matcher

Methods

compare :: Scope -> Scope -> Ordering #

(<) :: Scope -> Scope -> Bool #

(<=) :: Scope -> Scope -> Bool #

(>) :: Scope -> Scope -> Bool #

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

max :: Scope -> Scope -> Scope #

min :: Scope -> Scope -> Scope #

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

Update the scope with the message corresponding to a table key

Since: 1.3.0.0

inIndex :: Int -> Matcher a -> Matcher a Source #

Update the scope with the message corresponding to an array index

Since: 1.3.0.0