Portability | portable |
---|---|
Stability | experimental |
Maintainer | Leon P Smith <leon@melding-monads.com> |
Safe Haskell | None |
A set of combinators for high-level configuration parsing.
- class Applicative m => ConfigParser m
- data ConfigParserA a
- data ConfigParserM a
- data ConfigError = ConfigError {}
- data ConfigErrorLocation
- = KeyMissing [Name]
- | Key FilePath Name
- data ConversionError = ConversionError {}
- data ConversionErrorWhy
- = MissingValue
- | ExtraValues
- | ExhaustedValues
- | TypeError
- | ValueError
- | MonadFail
- | OtherError
- data Config
- data ConfigTransform
- unsafeBind :: ConfigParserA a -> (a -> ConfigParserA b) -> ConfigParserA b
- runParser :: ConfigParser m => m a -> Config -> (Maybe a, [ConfigError])
- runParserA :: ConfigParserA a -> Config -> (Maybe a, [ConfigError])
- runParserM :: ConfigParserM a -> Config -> (Maybe a, [ConfigError])
- parserA :: ConfigParser m => ConfigParserA a -> m a
- parserM :: ConfigParser m => ConfigParserM a -> m a
- subassocs :: ConfigParser m => Name -> m [(Name, Value)]
- subassocs' :: ConfigParser m => Name -> m [(Name, Value)]
- subgroups :: ConfigParser m => Name -> m [Name]
- localConfig :: ConfigParser m => ConfigTransform -> m a -> m a
- union :: ConfigTransform -> ConfigTransform -> ConfigTransform
- subconfig :: Text -> ConfigTransform -> ConfigTransform
- superconfig :: Text -> ConfigTransform -> ConfigTransform
- recover :: ConfigParser m => m a -> m (Maybe a)
- key :: (ConfigParser m, FromMaybeValue a) => Name -> m a
- keyWith :: ConfigParser m => Name -> MaybeParser a -> m a
Documentation
class Applicative m => ConfigParser m Source
The ConfigParser
type class abstracts over ConfigParserM
and
ConfigParserA
. This is intended to be a closed typeclass, without
any additional instances.
data ConfigParserA a Source
A
computation produces a value of type ConfigParserM
a
from a given Maybe
aConfig
, in addition to a list of diagnostic messages.
After executing a subcomputation that returns a Nothing
value,
computations of type ConfigParserA
will continue to run in order to
produce more error messages. For this reason, ConfigParserA
does
not have a proper Monad
instance. (But see unsafeBind
)
data ConfigParserM a Source
A
computation produces a value of type ConfigParserM
a
from a given Maybe
aConfig
, in addition to a list of diagnostic messages
which may be interpreted as warnings or errors as deemed appropriate.
If the value returned by a computation is Nothing
, then no subsequent
actions (e.g. via <*>
or >>=
) will be performed.
data ConfigError Source
An error (or warning) from a higher-level parser of a configuration file.
data ConversionError Source
data ConversionErrorWhy Source
data ConfigTransform Source
Conceptually, a ConfigTransform
is a function Config
->
Config
.
It's a restricted subset of such functions as to preserve the possibility
of reliable dependency tracking in later versions of configurator-ng.
Monoid ConfigTransform |
|
unsafeBind :: ConfigParserA a -> (a -> ConfigParserA b) -> ConfigParserA bSource
The purpose of this function is to make it convenient to use do-notation
with ConfigParserA
, either by defining a Monad instance or locally
rebinding '(>>=)'. Be warned that this is an abuse, and incorrect
usage can result in exceptions. A safe way to use this function
would be to treat is as applicative-do notation. A safer alternative
would be to use the ApplicativeDo
language extension available in
GHC 8.0 and not use this function at all.
runParser :: ConfigParser m => m a -> Config -> (Maybe a, [ConfigError])Source
runParserA :: ConfigParserA a -> Config -> (Maybe a, [ConfigError])Source
Exactly the same as runParser
, except less polymorphic
runParserM :: ConfigParserM a -> Config -> (Maybe a, [ConfigError])Source
Exactly the same as runParser
, except less polymorphic
parserA :: ConfigParser m => ConfigParserA a -> m aSource
Lift a ConfigParserA
action into a generic ConfigParser
action. Note that this does not change the semantics of the
argument, it just allows a ConfigParserA
computation to be
embedded in another ConfigParser
computation of either variant.
parserM :: ConfigParser m => ConfigParserM a -> m aSource
Lift a ConfigParserM
action into a generic ConfigParser
action. Note that this does not change the semantics of the
argument, it just allows a ConfigParserM
computation to be
embedded in another ConfigParser
computation of either variant.
subassocs' :: ConfigParser m => Name -> m [(Name, Value)]Source
subgroups :: ConfigParser m => Name -> m [Name]Source
localConfig :: ConfigParser m => ConfigTransform -> m a -> m aSource
recover :: ConfigParser m => m a -> m (Maybe a)Source
key :: (ConfigParser m, FromMaybeValue a) => Name -> m aSource
keyWith :: ConfigParser m => Name -> MaybeParser a -> m aSource