Copyright | (c) Eric Mertens 2023 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- data Matcher a
- data Result e a
- data MatchMessage = MatchMessage {
- matchPath :: [Scope]
- matchMessage :: String
- runMatcher :: Matcher a -> Result MatchMessage a
- withScope :: Scope -> Matcher a -> Matcher a
- getScope :: Matcher [Scope]
- warning :: String -> Matcher ()
- data Scope
- inKey :: String -> Matcher a -> Matcher a
- inIndex :: Int -> Matcher a -> Matcher a
Types
Computations that result in a Result
and which track a list
of nested contexts to assist in generating warnings and error
messages.
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
Instances
(Read e, Read a) => Read (Result e a) Source # | Default instance |
(Show e, Show a) => Show (Result e a) Source # | Default instance |
(Eq e, Eq a) => Eq (Result e a) Source # | Default instance |
(Ord e, Ord a) => Ord (Result e a) Source # | Default instance |
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
MatchMessage | |
|
Instances
Read MatchMessage Source # | Default instance |
Defined in Toml.FromValue.Matcher readsPrec :: Int -> ReadS MatchMessage # readList :: ReadS [MatchMessage] # | |
Show MatchMessage Source # | Default instance |
Defined in Toml.FromValue.Matcher showsPrec :: Int -> MatchMessage -> ShowS # show :: MatchMessage -> String # showList :: [MatchMessage] -> ShowS # | |
Eq MatchMessage Source # | Default instance |
Defined in Toml.FromValue.Matcher (==) :: MatchMessage -> MatchMessage -> Bool # (/=) :: MatchMessage -> MatchMessage -> Bool # | |
Ord MatchMessage Source # | Default instance |
Defined in Toml.FromValue.Matcher compare :: MatchMessage -> MatchMessage -> Ordering # (<) :: MatchMessage -> MatchMessage -> Bool # (<=) :: MatchMessage -> MatchMessage -> Bool # (>) :: MatchMessage -> MatchMessage -> Bool # (>=) :: MatchMessage -> MatchMessage -> Bool # max :: MatchMessage -> MatchMessage -> MatchMessage # min :: MatchMessage -> MatchMessage -> MatchMessage # |
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
Scope helpers
Scopes for TOML message.
Since: 1.3.0.0
ScopeIndex Int | zero-based array index |
ScopeKey String | key in a table |