configurator-ng-0.0.0.1: The next generation of configuration management

Copyright(c) 2016 Leon P Smith
LicenseBSD3
MaintainerLeon P Smith <leon@melding-monads.com>
Safe HaskellNone
LanguageHaskell98

Data.Configurator.FromValue

Contents

Description

 

Synopsis

Documentation

data MaybeParser a #

An action to turn a Maybe Value into zero or one values of type a, and possibly report errors/warnings.

class FromMaybeValue a where #

Instances

FromMaybeValue Bool # 
FromMaybeValue Char # 
FromMaybeValue Double # 
FromMaybeValue Float # 
FromMaybeValue Int # 
FromMaybeValue Int8 # 
FromMaybeValue Int16 # 
FromMaybeValue Int32 # 
FromMaybeValue Int64 # 
FromMaybeValue Integer # 
FromMaybeValue Word # 
FromMaybeValue Word8 # 
FromMaybeValue Word16 # 
FromMaybeValue Word32 # 
FromMaybeValue Word64 # 
FromMaybeValue ByteString # 
FromMaybeValue ByteString # 
FromMaybeValue Text # 
FromMaybeValue Text # 
FromMaybeValue String # 
FromMaybeValue CFloat # 
FromMaybeValue CDouble # 
FromMaybeValue Scientific # 
FromMaybeValue Value # 
(Typeable * a, FromValue a) => FromMaybeValue [a] # 
FromValue a => FromMaybeValue (Maybe a) # 
(Typeable * a, Integral a) => FromMaybeValue (Ratio a) # 
(Typeable * a, HasResolution a) => FromMaybeValue (Fixed a) # 
(Typeable * a, RealFloat a) => FromMaybeValue (Complex a) # 
(Typeable * a, FromValue a, Typeable * b, FromValue b) => FromMaybeValue (a, b) # 

Methods

fromMaybeValue :: MaybeParser (a, b) #

(Typeable * a, FromValue a, Typeable * b, FromValue b, Typeable * c, FromValue c) => FromMaybeValue (a, b, c) # 

Methods

fromMaybeValue :: MaybeParser (a, b, c) #

(Typeable * a, FromValue a, Typeable * b, FromValue b, Typeable * c, FromValue c, Typeable * d, FromValue d) => FromMaybeValue (a, b, c, d) # 

Methods

fromMaybeValue :: MaybeParser (a, b, c, d) #

optionalValue :: ValueParser a -> MaybeParser (Maybe a) #

Turns a ValueParser into a MaybeParser. If the Maybe Value the parser is passed is Nothing (which normally means a key was not found), then this returns the Nothing value with no errors or warnings. Otherwise, it passes the Value to the subparser. If the subparser returns a result value, then this returns Just the value. Otherwise, if the subparser does not return a value, then this does not return a value.

Any errors/warnings returned by the subparser are returned exactly as-is.

requiredValue :: forall a. Typeable a => ValueParser a -> MaybeParser a #

Turns a ValueParser into a MaybeParser. If the Maybe Value the parser is passed is Nothing (which normally means a key was not found), then this does not return a value and also returns a missingValueError. Otherwise, the Value is passed to the subparser, and the result and any errors/warnings are returned as-is.

data ValueParser a #

An action to turn a Value into zero or one values of type a, and possibly report errors/warnings.

class FromValue a where #

Minimal complete definition

fromValue

Methods

fromValue :: ValueParser a #

Instances

FromValue Bool # 
FromValue Char # 
FromValue Double # 
FromValue Float # 
FromValue Int # 
FromValue Int8 # 
FromValue Int16 # 
FromValue Int32 # 
FromValue Int64 # 
FromValue Integer # 
FromValue Word # 
FromValue Word8 # 
FromValue Word16 # 
FromValue Word32 # 
FromValue Word64 # 
FromValue ByteString # 
FromValue ByteString # 
FromValue Text # 
FromValue Text # 
FromValue String # 
FromValue CFloat # 
FromValue CDouble # 
FromValue Scientific # 
FromValue Value # 
(Typeable * a, FromValue a) => FromValue [a] # 

Methods

fromValue :: ValueParser [a] #

(Typeable * a, Integral a) => FromValue (Ratio a) # 
(Typeable * a, HasResolution a) => FromValue (Fixed a) # 
(Typeable * a, RealFloat a) => FromValue (Complex a) # 
(Typeable * a, FromValue a, Typeable * b, FromValue b) => FromValue (a, b) # 

Methods

fromValue :: ValueParser (a, b) #

(Typeable * a, FromValue a, Typeable * b, FromValue b, Typeable * c, FromValue c) => FromValue (a, b, c) # 

Methods

fromValue :: ValueParser (a, b, c) #

(Typeable * a, FromValue a, Typeable * b, FromValue b, Typeable * c, FromValue c, Typeable * d, FromValue d) => FromValue (a, b, c, d) # 

Methods

fromValue :: ValueParser (a, b, c, d) #

data ListParser a #

An action to turn a [Value] into zero or one values of type a, and possibly report errors/warnings.

class FromListValue a where #

Minimal complete definition

fromListValue

Instances

(Typeable * a, FromValue a, Typeable * b, FromValue b) => FromListValue (a, b) # 

Methods

fromListValue :: ListParser (a, b) #

(Typeable * a, FromValue a, Typeable * b, FromValue b, Typeable * c, FromValue c) => FromListValue (a, b, c) # 

Methods

fromListValue :: ListParser (a, b, c) #

(Typeable * a, FromValue a, Typeable * b, FromValue b, Typeable * c, FromValue c, Typeable * d, FromValue d) => FromListValue (a, b, c, d) # 

Methods

fromListValue :: ListParser (a, b, c, d) #

listValue :: forall a. Typeable a => ListParser a -> ValueParser a #

Turns a ListParser into a ValueParser. It first checks that the Value the ValueParser is passed is a List Value. If it's not, this returns no result as well as a typeError. Otherwise, it passes the list of results to the ListParser subparser.

If the subparser consumes all of the list elements, this returns the value and errors as-is. If there are leftover list elements, this returns the value, and adds a message warning of the extra elements to the list of errors.

The difference from 'listValue\'' is that this returns values with unconsumed list elements (discarding the list elements).

listValue' :: forall a. Typeable a => ListParser a -> ValueParser a #

Turns a ListParser into a ValueParser. It first checks that the Value the ValueParser is passed is a List Value. If it's not, this returns no result as well as a typeError. Otherwise, it passes the list of results to the ListParser subparser.

If the subparser consumes all of the list elements, this returns the value and errors as-is. If there are leftover list elements, this returns no value, and adds a message warning of the extra elements to the list of errors.

The difference from listValue is that this never returns a value if there are unconsumed list elements. (discarding both the value returned and the list element.)

listElem :: forall a. Typeable a => ValueParser a -> ListParser a #

Turns a ValueParser into a ListParser that consumes a single element.

If there are no list elements left, this returns list error value and an ExhaustedValues error.

If there is an element left, it is passed to the value parser. If the value parser returns a value, it is returned along with the errors as-is. If the value parser returns no value, then this returns a non-list error value and the list of errors returned by the value parser.

The difference between a "list error value" and a "non-list error value", is that the Alternative instance for ListParser recovers from "list error" values but does not recover from "non-list error" values. This behavior was chosen so that the optional, some, and many combinators work on ListParsers in a way that is hopefully least surprising.

Assorted primitive value parsers

integralValue :: forall a. (Typeable a, Integral a) => ValueParser a #

realFloatValue :: forall a. (Typeable a, RealFloat a) => ValueParser a #

fixedValue :: forall a. (Typeable a, HasResolution a) => ValueParser (Fixed a) #