ecluse
Safe HaskellNone
LanguageGHC2021

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

Group decoding

data GroupDecoder a Source #

An applicative group decoder: each key it declares is one it accepts and one it reads.

Instances

Instances details
Applicative GroupDecoder Source # 
Instance details

Defined in Ecluse.Config.Parser

Functor GroupDecoder Source # 
Instance details

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

data TagCase a Source #

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.

parsePort :: String -> Int -> Parser Int Source #

A listener port: 0..65535, where 0 asks the OS for an ephemeral port.

parseCodeArtifactDuration :: String -> Value -> Parser Natural Source #

Accept seconds in CodeArtifact's 900..43200 range before the first token mint.