Safe Haskell | None |
---|---|
Language | Haskell2010 |
DSL for parsing of parameters.
- data Params a
- param :: Text -> Value a -> Params a
- defaultParam :: DefaultValue a => Text -> Params a
- defaultParams1 :: DefaultValue a => Text -> Params a
- defaultParams2 :: (DefaultValue a, DefaultValue b) => Text -> Text -> Params (a, b)
- defaultParams3 :: (DefaultValue a, DefaultValue b, DefaultValue c) => Text -> Text -> Text -> Params (a, b, c)
- defaultParams4 :: (DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d) => Text -> Text -> Text -> Text -> Params (a, b, c, d)
- defaultParams5 :: (DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e) => Text -> Text -> Text -> Text -> Text -> Params (a, b, c, d, e)
- defaultParams6 :: (DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e, DefaultValue f) => Text -> Text -> Text -> Text -> Text -> Text -> Params (a, b, c, d, e, f)
- defaultParams7 :: (DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e, DefaultValue f, DefaultValue g) => Text -> Text -> Text -> Text -> Text -> Text -> Text -> Params (a, b, c, d, e, f, g)
- data Value a
- parser :: Parser a -> Value a
- matcher :: (Text -> Either Text a) -> Value a
- list :: Value a -> Value [a]
- maybe :: Value a -> Value (Maybe a)
- class DefaultValue value where
Documentation
Parser of a product of parameters.
Can be composed using the Applicative interface.
defaultParam :: DefaultValue a => Text -> Params a Source #
Parse a param by its name using the implicit default parser.
Multi-arity default param parser helpers
defaultParams1 :: DefaultValue a => Text -> Params a Source #
Same as defaultParam
.
defaultParams2 :: (DefaultValue a, DefaultValue b) => Text -> Text -> Params (a, b) Source #
A helper abstracting over the Applicative composition of multiple defaultParam
.
defaultParams3 :: (DefaultValue a, DefaultValue b, DefaultValue c) => Text -> Text -> Text -> Params (a, b, c) Source #
A helper abstracting over the Applicative composition of multiple defaultParam
.
defaultParams4 :: (DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d) => Text -> Text -> Text -> Text -> Params (a, b, c, d) Source #
A helper abstracting over the Applicative composition of multiple defaultParam
.
defaultParams5 :: (DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e) => Text -> Text -> Text -> Text -> Text -> Params (a, b, c, d, e) Source #
A helper abstracting over the Applicative composition of multiple defaultParam
.
defaultParams6 :: (DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e, DefaultValue f) => Text -> Text -> Text -> Text -> Text -> Text -> Params (a, b, c, d, e, f) Source #
A helper abstracting over the Applicative composition of multiple defaultParam
.
defaultParams7 :: (DefaultValue a, DefaultValue b, DefaultValue c, DefaultValue d, DefaultValue e, DefaultValue f, DefaultValue g) => Text -> Text -> Text -> Text -> Text -> Text -> Text -> Params (a, b, c, d, e, f, g) Source #
A helper abstracting over the Applicative composition of multiple defaultParam
.
Value parsers
A parser of a parameter value.
list :: Value a -> Value [a] Source #
Lifts a single value parser to the parser of a list of values.
Useful for decoding lists of values of the same name. E.g., it'll work for the both following cases:
?param[]=1¶m[]=2
?param=1¶m=2
In both cases the name of the parameter to look up will be "param".
maybe :: Value a -> Value (Maybe a) Source #
Lifts a single value parser to the parser of a possibly specified value.
It's useful for decoding the difference between the following two cases:
?param=value
?param
Implicit default value parsers
class DefaultValue value where Source #
Provides a default value parser.
defaultValue :: Value value Source #
DefaultValue Bool Source # | Interprets all the following inputs case-insensitively:
"1" or "0", "true" or "false", "yes" or "no", "y" or "n", "t" or "f".
The absense of a value is interpreted as |
DefaultValue Char Source # | |
DefaultValue Double Source # | |
DefaultValue Int Source # | |
DefaultValue Int8 Source # | |
DefaultValue Int16 Source # | |
DefaultValue Int32 Source # | |
DefaultValue Int64 Source # | |
DefaultValue Integer Source # | |
DefaultValue Word Source # | |
DefaultValue Word8 Source # | |
DefaultValue Word16 Source # | |
DefaultValue Word32 Source # | |
DefaultValue Word64 Source # | |
DefaultValue ByteString Source # | Encodes the input using UTF8. |
DefaultValue Text Source # | |
DefaultValue String Source # | |
DefaultValue Scientific Source # | |
DefaultValue TimeOfDay Source # | |
DefaultValue TimeZone Source # | |
DefaultValue UTCTime Source # | |
DefaultValue Day Source # | |
DefaultValue a => DefaultValue [a] Source # | Uses |
DefaultValue a => DefaultValue (Maybe a) Source # | Uses |