tasty-0.5.2.1: Modern and extensible testing framework

Safe HaskellNone

Test.Tasty.Options

Contents

Description

Extensible options. They are used for provider-specific settings, ingredient-specific settings and core settings (such as the test name pattern).

Synopsis

IsOption class

class Typeable v => IsOption v whereSource

An option is a data type that inhabits the IsOption type class.

Methods

defaultValue :: vSource

The value to use if the option was not supplied explicitly

parseValue :: String -> Maybe vSource

Try to parse an option value from a string

optionName :: Tagged v StringSource

The option name. It is used to form the command line option name, for instance. Therefore, it had better not contain spaces or other fancy characters. It is recommended to use dashes instead of spaces.

optionHelp :: Tagged v StringSource

The option description or help string. This can be an arbitrary string.

optionCLParser :: Parser vSource

A command-line option parser.

It has a default implementation in terms of the other methods. You may want to override it in some cases (e.g. add a short flag).

Even if you override this, you still should implement all the methods above, to allow alternative interfaces.

Option sets and operations

data OptionSet Source

A set of options. Only one option of each type can be kept.

If some option has not been explicitly set, the default value is used.

Instances

Monoid OptionSet

Later options override earlier ones

setOption :: IsOption v => v -> OptionSet -> OptionSetSource

Set the option value

changeOption :: forall v. IsOption v => (v -> v) -> OptionSet -> OptionSetSource

Change the option value

lookupOption :: forall v. IsOption v => OptionSet -> vSource

Query the option value

data OptionDescription whereSource

The purpose of this data type is to capture the dictionary corresponding to a particular option.

Constructors

Option :: IsOption v => Proxy v -> OptionDescription 

Utilities

safeRead :: Read a => String -> Maybe aSource

Safe read function. Defined here for convenience to use for parseValue.