Copyright | (c) Eric Mertens 2017 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
This module automates the extraction of a decoded value from a configuration value according to a specification as built using Config.Schema.Spec.
- loadValue :: ValueSpecs a -> Value p -> Either (NonEmpty (LoadError p)) a
- loadValueFromFile :: ValueSpecs a -> FilePath -> IO a
- newtype SchemaError = SchemaError (NonEmpty (LoadError Position))
- data LoadError p = LoadError p [Text] Problem
- data Problem
Documentation
:: ValueSpecs a | specification |
-> Value p | value |
-> Either (NonEmpty (LoadError p)) a | errors or decoded value |
Match a Value
against a ValueSpecs
and return either
the interpretation of that value or the list of errors
encountered.
:: ValueSpecs a | specification |
-> FilePath | filename |
-> IO a |
Read a configuration file, parse it, and validate it according to the given specification.
Throws IOError
, ParseError
, or SchemaError
Errors
newtype SchemaError Source #
Newtype wrapper for schema load errors.
Show SchemaError Source # | |
Exception SchemaError Source # | Custom |
Type for errors that can be encountered while decoding a value according to a specification. The error includes a key path indicating where in the configuration file the error occurred.
Problems that can be encountered when matching a Value
against a ValueSpecs
.
MissingSection Text | missing section name |
UnusedSection Text | unused section names |
SpecMismatch Text | failed specification name |