crux-0.7: Simple top-level library for Crucible Simulation
Safe HaskellSafe-Inferred
LanguageHaskell2010

Crux.Config

Description

This module deals with loading configurations.

Synopsis

Writing configurations

data Config opts Source #

Loading options from multiple sources. First we load configuration from a file, then we consider environment variables, and finally we update using the command line flags. If there is no configuration file provided, then this is equivalent to having an empty configuration file, so the config file schema should be able to cope with missing settings.

Constructors

Config 

Fields

cfgJoin :: Config a -> Config b -> Config (a, b) Source #

Configuration files

data SectionsSpec a #

A list of section specifications used to process a whole group of key-value pairs. Multiple section specifications can be combined using this type's Applicative instance.

To create SectionsSpec values see Config.Schema.Spec

Instances

Instances details
Applicative SectionsSpec 
Instance details

Defined in Config.Schema.Types

Functor SectionsSpec 
Instance details

Defined in Config.Schema.Types

Methods

fmap :: (a -> b) -> SectionsSpec a -> SectionsSpec b #

(<$) :: a -> SectionsSpec b -> SectionsSpec a #

section Source #

Arguments

:: Text

Option name

-> ValueSpec a

What type of value we expect

-> a

Default value to use if option not specified

-> Text

Documentation

-> SectionsSpec a 

An option that can be configured in the file.

sectionMaybe Source #

Arguments

:: Text

Option name

-> ValueSpec a

What type of value we expect

-> Text

Documentation

-> SectionsSpec (Maybe a) 

yesOrNoSpec :: ValueSpec Bool #

Specification for using atoms yes and no to represent booleans True and False respectively

stringSpec :: ValueSpec String #

Specification for matching any text as a String

numSpec :: Num a => ValueSpec a #

Specification for matching any integral number.

fractionalSpec :: Fractional a => ValueSpec a #

Specification for matching any fractional number.

Since: config-schema-0.2.0.0

oneOrList #

Arguments

:: ValueSpec a

element specification

-> ValueSpec [a] 

Specification that matches either a single element or multiple elements in a list. This can be convenient for allowing the user to avoid having to specify singleton lists in the configuration file.

listSpec #

Arguments

:: ValueSpec a

element specification

-> ValueSpec [a] 

Primitive specification for matching a list of values each satisfying a given element specification.

Environment variables

data EnvDescr opts Source #

How the value of an environment variable contributes to the options.

Constructors

EnvVar 

Fields

liftEnvDescr :: Lens' a b -> EnvDescr b -> EnvDescr a Source #

Lifts an EnvDescr for some smaller type b into an EnvDescr with the same name and documentation, but operating over a larger type a. Useful for embedding the options of another executable within an executable with possibly additional options.

liftOptDescr :: Lens' a b -> OptDescr b -> OptDescr a Source #

Lifts an OptDescr for some smaller type b into an OptDescr with the same name and documentation, but operating over a larger type a. Useful for embedding the options of another executable within an executable with possibly additional options.

Command line options

data OptDescr a #

Describe an option.

data ArgDescr a #

Describe an option argumnet.

Constructors

NoArg (OptSetter a)

This option does not take an argument.

ReqArg String (String -> OptSetter a)

This option has a required argument. The string describes the type of the argument.

OptArg String (Maybe String -> OptSetter a)

This option has an optional argument. The string describes the type of the argument.

type OptSetter a = a -> Either String a #

Manipulate options of type a, with support for errors.

parsePosNum :: (Read a, Num a, Ord a) => String -> (a -> opts -> opts) -> String -> OptSetter opts Source #