| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Config.Parser
Description
The key vocabulary every configuration group decodes through (Ecluse.Config.Aeson).
One declaration list is both the accepted-key list and the read list, so a key no field reads
cannot pass unnoticed and must be declared with unreadKey. Each refusal carries the
group-qualified label and the Aeson path, so a nested type error names the setting an operator
wrote.
Synopsis
- data GroupDecoder a
- decodeGroup :: String -> GroupDecoder a -> KeyMap Value -> Parser a
- decodeBareGroup :: String -> GroupDecoder a -> KeyMap Value -> Parser a
- requiredKey :: FromJSON b => Key -> (String -> b -> Parser a) -> GroupDecoder a
- optionalKey :: FromJSON b => Key -> (String -> b -> Parser a) -> GroupDecoder (Maybe a)
- optionalKeyOr :: FromJSON b => Key -> b -> (String -> b -> Parser a) -> GroupDecoder a
- plainKey :: FromJSON a => Key -> GroupDecoder a
- optionalPlainKey :: FromJSON a => Key -> GroupDecoder (Maybe a)
- optionalPlainKeyOr :: FromJSON a => Key -> a -> GroupDecoder a
- nestedKey :: Key -> (KeyMap Value -> Parser a) -> GroupDecoder a
- unreadKey :: Key -> GroupDecoder ()
- data TagCase a = TagCase Key (GroupDecoder a)
- taggedTarget :: [TagCase a] -> String -> Value -> Parser a
- expectString :: String -> (Text -> Parser a) -> Value -> Parser a
- commaSeparated :: String -> (Text -> Parser a) -> Value -> Parser [a]
- valueKind :: Value -> String
- rejectSecretKeys :: KeyMap Value -> Parser ()
- parseRegistryUrl :: String -> Value -> Parser RegistryUrl
- parseEnum :: (Text -> Either Text a) -> String -> Value -> Parser a
- parseHttpUrl :: String -> Value -> Parser Url
- parseQueueUrl :: String -> Value -> Parser QueueUrl
- parseAdvisoryStoreUrl :: String -> Value -> Parser AdvisoryStoreUrl
- parsePort :: String -> Int -> Parser Int
- parseCodeArtifactDuration :: String -> Value -> Parser Natural
Group decoding
data GroupDecoder a Source #
An applicative group decoder: each key it declares is one it accepts and one it reads.
Instances
| Applicative GroupDecoder Source # | |
Defined in Ecluse.Config.Parser Methods pure :: a -> GroupDecoder a # (<*>) :: GroupDecoder (a -> b) -> GroupDecoder a -> GroupDecoder b # liftA2 :: (a -> b -> c) -> GroupDecoder a -> GroupDecoder b -> GroupDecoder c # (*>) :: GroupDecoder a -> GroupDecoder b -> GroupDecoder b # (<*) :: GroupDecoder a -> GroupDecoder b -> GroupDecoder a # | |
| Functor GroupDecoder Source # | |
Defined in Ecluse.Config.Parser Methods fmap :: (a -> b) -> GroupDecoder a -> GroupDecoder b # (<$) :: a -> GroupDecoder b -> GroupDecoder a # | |
decodeGroup :: String -> GroupDecoder a -> KeyMap Value -> Parser a Source #
Refuse unknown keys before reading values. Refinement labels use noun.key.
decodeBareGroup :: String -> GroupDecoder a -> KeyMap Value -> Parser a Source #
Decode with bare refinement labels when the enclosing parser supplies the group context.
requiredKey :: FromJSON b => Key -> (String -> b -> Parser a) -> GroupDecoder a Source #
Decode and refine a required key. Refinements receive its group-qualified label.
optionalKey :: FromJSON b => Key -> (String -> b -> Parser a) -> GroupDecoder (Maybe a) Source #
requiredKey for an optional key: an absent or null one yields Nothing.
optionalKeyOr :: FromJSON b => Key -> b -> (String -> b -> Parser a) -> GroupDecoder a Source #
requiredKey for an optional key whose absence reads as fallback before parse sees it.
plainKey :: FromJSON a => Key -> GroupDecoder a Source #
A required key its own FromJSON instance decodes whole, with no further refusal.
optionalPlainKey :: FromJSON a => Key -> GroupDecoder (Maybe a) Source #
plainKey for an optional key.
optionalPlainKeyOr :: FromJSON a => Key -> a -> GroupDecoder a Source #
plainKey for an optional key, with the value an absent one reads as.
nestedKey :: Key -> (KeyMap Value -> Parser a) -> GroupDecoder a Source #
Decode an absent group as an empty object so its required keys determine the refusal.
unreadKey :: Key -> GroupDecoder () Source #
A key the group accepts and no field reads.
Tagged targets
One tag a target key admits: the tag as an operator writes it, and the group under it.
Constructors
| TagCase Key (GroupDecoder a) |
taggedTarget :: [TagCase a] -> String -> Value -> Parser a Source #
Admit exactly one store tag and only the keys its decoder declares.
Value shapes
expectString :: String -> (Text -> Parser a) -> Value -> Parser a Source #
Refuse a non-string with its setting label and JSON kind, without quoting its value.
commaSeparated :: String -> (Text -> Parser a) -> Value -> Parser [a] Source #
A blank string gives no entries. Empty comma-separated entries still reach parseEntry.
rejectSecretKeys :: KeyMap Value -> Parser () Source #
Refuse document credentials without including their values in the error.
Leaf parsers
parseRegistryUrl :: String -> Value -> Parser RegistryUrl Source #
Refuse credentials before any URL refusal can quote the input.
parseEnum :: (Text -> Either Text a) -> String -> Value -> Parser a Source #
Decode a named enum and retain the setting label on refusal.
parseHttpUrl :: String -> Value -> Parser Url Source #
Parse an HTTP(S) URL without credentials. Plain HTTP remains legal for loopback deployments.
parseQueueUrl :: String -> Value -> Parser QueueUrl Source #
Parse a queue destination whose shape determines its provider.
parseAdvisoryStoreUrl :: String -> Value -> Parser AdvisoryStoreUrl Source #
Parse an advisory object store whose scheme determines its provider.