configurator-ng-0.0.0.0: The next generation of configuration management

Portabilityportable
Stabilityexperimental
MaintainerLeon P Smith <leon@melding-monads.com>
Safe HaskellNone

Data.Configurator.Parser

Description

A set of combinators for high-level configuration parsing.

Synopsis

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 ConfigParserM a computation produces a value of type Maybe a from a given Config, 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 ConfigParserM a computation produces a value of type Maybe a from a given Config, 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 Config Source

A Config is a finite map from Text to Value.

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.

Instances

Monoid ConfigTransform

mempty is the identity ConfigTransform, mappend is the composition of two ConfigTransforms.

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.

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.

localConfig :: ConfigParser m => ConfigTransform -> m a -> m aSource

Modifies the Config that a subparser is operating on. This is perfectly analogous to local.

recover :: ConfigParser m => m a -> m (Maybe a)Source

Given the expression recover action, the action will be run, and if it returns no value, recover action will return Nothing. If action returns the value a, then recover action will return the value Just a. Any errors or warnings are passed through as-is.