glirc-2.15: Console IRC client

Copyright(c) Eric Mertens, 2016
Safe HaskellNone




This module provides tools for producing structured configuration information out of configuration values.


Configuration parsing

data ConfigParser a Source #

Configuration parser tracking current location and for propagating error information.

decodeConfig :: FromConfig a => Value -> Either Text a Source #

Parse a Value according to the method in the FromConfig

runConfigParser :: ConfigParser a -> Either Text a Source #

Run a top-level parser to either get the parsed value or an error message.

failure Source #


:: Text

error message

-> ConfigParser a 

A parser that always fails with the given error message.

extendLoc :: Text -> ConfigParser a -> ConfigParser a Source #

Embed a parser into an extended location. This is used when parsing inside a section.

class FromConfig a where Source #

Class for types that have a well-known way to parse them.

Minimal complete definition



parseConfig :: Value -> ConfigParser a Source #

Parse a value


FromConfig Bool Source #

Matches yes as True and no as 'False.

FromConfig Integer Source #

Matches Number values ignoring the base

FromConfig Text Source #

Matches Text values.

FromConfig Atom Source #

Matches Atom values

FromConfig a => FromConfig [a] Source #

Matches List values, extends the error location with a zero-based index

Integral a => FromConfig (Ratio a) Source #

Matches Number values ignoring the base

Parser wrappers

Section parsing

parseSections :: SectionParser a -> Value -> ConfigParser a Source #

Run a SectionParser given particular Value. This will only succeed when the value is a Sections and the section parser consumes all of the sections from that value.

sectionReq :: FromConfig a => Text -> SectionParser a Source #

Parse the value at the given section or fail.

sectionReqWith :: (Value -> ConfigParser a) -> Text -> SectionParser a Source #

Parse the value at the given section or fail.

sectionOpt :: FromConfig a => Text -> SectionParser (Maybe a) Source #

sectionOpt = sectionOptWith parseConfig

sectionOptWith :: (Value -> ConfigParser a) -> Text -> SectionParser (Maybe a) Source #

Parses the value stored at the given section with the given parser. Nothing is returned if the section is missing. Just is returned if the parse succeeds Error is raised if the section is present but the parse fails

liftConfigParser :: ConfigParser a -> SectionParser a Source #

Lift a ConfigParser into a SectionParser leaving the current section information unmodified.