Copyright | © Jonathan Lorimer 2023 |
---|---|
License | MIT |
Maintainer | jonathanlorimer@pm.me |
Stability | stable |
Safe Haskell | None |
Language | Haskell2010 |
This module contains the type classes for parsing a configuration type from
a source, as well as instances for most basic Haskell types. One important
interaction to note is that we use a default instance for ConfigParser
that dispatches to a ValueParser
instances. This is how we distinguish
between a "parser" that just navigates the tree representation of our
configuration and a parser that actually converts from text to our Haskell
type.
Since: 0.0.2.0
Synopsis
- class ConfigParser a where
- parseConfig :: KeyTree Text Text -> Either ConfigParseError a
- class ValueParser a where
- type Parser = Parsec Void Text
- data ConfigParseError
Parser Typeclasses
class ConfigParser a where Source #
This is the instance that allows us to parse a result from our configuration source after we have retrieved it.
Since: 0.0.2.0
Nothing
parseConfig :: KeyTree Text Text -> Either ConfigParseError a Source #
Takes in the tree representation of our configuration and parses out our Haskell type
The default instance allows us to wrap a ValueParser
in a
ConfigParser
, this allows us to use a uniform typeclass for parsing,
but at the same time distinguish between traversing the key structure and
actually parsing the textual value.
default parseConfig :: ValueParser a => KeyTree Text Text -> Either ConfigParseError a Source #
Instances
class ValueParser a where Source #
This is a text parser that we use to parse the eventual values we get from a configuration.
Since: 0.0.2.0
Instances
Parser Types
data ConfigParseError Source #
Type errors we can encounter when parsing
Since: 0.0.2.0
MissingKey | We encountered a |
ExpectedKeyFoundValue | Expected to find a subtree aka a |
ExpectedValueFoundForest | Expected to find a |
ValueParseError | Ran a |
|