Safe Haskell | None |
---|---|
Language | Haskell2010 |
Optima
Synopsis
- params :: Text -> Params a -> IO a
- data Params a
- param :: Maybe Char -> Text -> Param a -> Params a
- group :: Text -> ParamGroup a -> Params a
- data ParamGroup a
- member :: Text -> Param a -> ParamGroup a
- subgroup :: Text -> ParamGroup a -> ParamGroup a
- data Param a
- value :: Text -> Default a -> ValueFormat a -> Value a -> Param a
- flag :: Text -> Param ()
- data Value a
- explicitlyParsed :: Parser a -> Value a
- implicitlyParsed :: LenientParser a => Value a
- data Default a
- explicitlyRepresented :: (a -> Text) -> a -> Default a
- showable :: Show a => a -> Default a
- defaultless :: Default a
- data ValueFormat a
- formattedByEnum :: (Bounded a, Enum a) => (a -> Text) -> ValueFormat a
- formattedByEnumUsingShow :: (Bounded a, Enum a, Show a) => ValueFormat a
- unformatted :: ValueFormat a
IO
Execute the parameters parser in IO, throwing an exception if anything goes wrong.
Params
Parameters product parser. Should be used for composition of all application parameters.
Lift a single parameter parser.
Arguments
:: Text | Prefix for the long names of the parameters. If empty, then there'll be no prefixing |
-> ParamGroup a | |
-> Params a |
Lift a parameter group parser.
The param group cannot use short names, only long names.
ParamGroup
data ParamGroup a Source #
Parameter group, which gets identified by prefixing the names.
Should be used to define parameters, which only make sense in combination. E.g., a server config can be defined by providing port and host together.
Instances
Functor ParamGroup Source # | |
Defined in Optima Methods fmap :: (a -> b) -> ParamGroup a -> ParamGroup b # (<$) :: a -> ParamGroup b -> ParamGroup a # | |
Applicative ParamGroup Source # | |
Defined in Optima Methods pure :: a -> ParamGroup a # (<*>) :: ParamGroup (a -> b) -> ParamGroup a -> ParamGroup b # liftA2 :: (a -> b -> c) -> ParamGroup a -> ParamGroup b -> ParamGroup c # (*>) :: ParamGroup a -> ParamGroup b -> ParamGroup b # (<*) :: ParamGroup a -> ParamGroup b -> ParamGroup a # | |
Alternative ParamGroup Source # | |
Defined in Optima Methods empty :: ParamGroup a # (<|>) :: ParamGroup a -> ParamGroup a -> ParamGroup a # some :: ParamGroup a -> ParamGroup [a] # many :: ParamGroup a -> ParamGroup [a] # |
Arguments
:: Text | Long name of the parameter |
-> Param a | |
-> ParamGroup a |
Lift a param parser into parameter group.
Arguments
:: Text | Long name prefix |
-> ParamGroup a | |
-> ParamGroup a |
Unite a group by a shared prefix.
Param
Parameter parser.
Includes the description of the parameter.
Arguments
:: Text | Description. Can be empty |
-> Default a | Default value |
-> ValueFormat a | Value format |
-> Value a | |
-> Param a |
Create a single parameter parser from a value parser and meta information.
A parameter with no value. Fails if it's not present. Thus it can be composed using Alternative.
Value
Parameter value parser.
explicitlyParsed :: Parser a -> Value a Source #
Lift an Attoparsec parser into value parser.
implicitlyParsed :: LenientParser a => Value a Source #
Lift an implicit lenient Attoparsec parser into value parser.
Default
Default value with its textual representation.
explicitlyRepresented :: (a -> Text) -> a -> Default a Source #
Provide a default value with explicit textual representation.
showable :: Show a => a -> Default a Source #
Provide a default value with textual representation formed using the implicit Show instance.
defaultless :: Default a Source #
Provide no default value.
ValueFormat
data ValueFormat a Source #
Parameter description.
Instances
Functor ValueFormat Source # | |
Defined in Optima Methods fmap :: (a -> b) -> ValueFormat a -> ValueFormat b # (<$) :: a -> ValueFormat b -> ValueFormat a # |
formattedByEnum :: (Bounded a, Enum a) => (a -> Text) -> ValueFormat a Source #
Derive value format specification from the Enum instance and explicit mapping of values to their representations.
formattedByEnumUsingShow :: (Bounded a, Enum a, Show a) => ValueFormat a Source #
Derive value format specification from the Enum and Show instances.
unformatted :: ValueFormat a Source #
Avoid specifying the format.