| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Config.Parser
Description
Configuration key decoders with group-qualified refusal paths.
Each declared key is read or explicitly accepted through unreadKey.
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)
- optionalNonNullKey :: FromJSON a => Key -> GroupDecoder (Maybe 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]
- nonEmptyCommaSeparated :: String -> (Text -> Parser a) -> String -> Value -> Parser (NonEmpty a)
- projectedEntry :: String -> (Text -> Either e a) -> Text -> 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.
optionalNonNullKey :: FromJSON a => Key -> GroupDecoder (Maybe a) Source #
optionalPlainKey for a key that refuses a written null, where an empty value must not
read as the key's default.
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.
nonEmptyCommaSeparated :: String -> (Text -> Parser a) -> String -> Value -> Parser (NonEmpty a) Source #
Retain entry refusals before rejecting a configured list that names nothing.
projectedEntry :: String -> (Text -> Either e a) -> Text -> Parser a Source #
Read one list entry through a projection, refusing with the label and the quoted entry.
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.