configurator-0.3.0.0: Configuration management

Portabilityportable
Stabilityexperimental
MaintainerBryan O'Sullivan <bos@serpentine.com>
Safe HaskellNone

Data.Configurator.Types

Contents

Description

Types for working with configuration files.

Synopsis

Documentation

data AutoConfig Source

Directions for automatically reloading Config data.

Constructors

AutoConfig 

Fields

interval :: Int

Interval (in seconds) at which to check for updates to config files. The smallest allowed interval is one second.

onError :: SomeException -> IO ()

Action invoked when an attempt to reload a Config or notify a ChangeHandler causes an exception to be thrown.

If this action rethrows its exception or throws a new exception, the modification checking thread will be killed. You may want your application to treat that as a fatal error, as its configuration may no longer be consistent.

data Config Source

Configuration data.

type Name = TextSource

The name of a Config value.

data Value Source

A value in a Config.

Constructors

Bool Bool

A Boolean. Represented in a configuration file as on or off, true or false (case sensitive).

String Text

A Unicode string. Represented in a configuration file as text surrounded by double quotes.

Escape sequences:

  • \n - newline
  • \r - carriage return
  • \t - horizontal tab
  • \\ - backslash
  • \" - quotes
  • \uxxxx - Unicode character, encoded as four hexadecimal digits
  • \uxxxx\uxxxx - Unicode character (as two UTF-16 surrogates)
Number Rational

Integer.

List [Value]

Heterogeneous list. Represented in a configuration file as an opening square bracket "[", followed by a comma-separated series of values, ending with a closing square bracket "]".

class Configured a whereSource

This class represents types that can be automatically and safely converted from a Value to a destination type. If conversion fails because the types are not compatible, Nothing is returned.

For an example of compatibility, a Value of Bool True cannot be converted to an Int.

Methods

convert :: Value -> Maybe aSource

data Worth a Source

Constructors

Required 

Fields

worth :: a
 
Optional 

Fields

worth :: a
 

Instances

Exceptions

data ConfigError Source

An error occurred while processing a configuration file.

Constructors

ParseError FilePath String 

data KeyError Source

An error occurred while lookup up the given Name.

Constructors

KeyError Name 

Notification of configuration changes

data Pattern Source

A pattern specifying the name of a property that has changed.

This type is an instance of the IsString class. If you use the OverloadedStrings language extension and want to write a prefix-matching pattern as a literal string, do so by suffixing it with ".*", for example as follows:

 "foo.*"

If a pattern written as a literal string does not end with ".*", it is assumed to be exact.

type ChangeHandlerSource

Arguments

 = Name

Name of the changed property.

-> Maybe Value

Its new value, or Nothing if it has vanished.

-> IO () 

An action to be invoked if a configuration property is changed.

If this action is invoked and throws an exception, the onError function will be called.