Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Conftrack.Value
Synopsis
- key :: QuasiQuoter
- data Value
- data ConfigError
- newtype Key = Key (NonEmpty KeyPart)
- class ConfigValue a where
- fromConfig :: Value -> Either ConfigError a
- prettyValue :: a -> Text
- data Origin = forall a.ConfigValue a => Origin a Text
- type KeyPart = Text
- prefixedWith :: Key -> [KeyPart] -> Key
- withString :: (ByteString -> Either ConfigError a) -> Value -> Either ConfigError a
Documentation
key :: QuasiQuoter Source #
to write values of Key
easily
A generic value read from a config source, to be parsed into a more useful type
(see the ConfigValue
class).
Constructors
ConfigString ByteString | |
ConfigInteger Integer | |
ConfigMaybeInteger ByteString Integer | A value which may be an integer, but the source cannot say for sure, e.g. because
its values are entirely untyped. Use |
ConfigOther Text Text | |
ConfigBool Bool | |
ConfigNull |
data ConfigError Source #
Constructors
ParseError Text | |
TypeMismatch Text Value | |
NotPresent Key | |
Shadowed |
Instances
Show ConfigError Source # | |
Defined in Conftrack.Value Methods showsPrec :: Int -> ConfigError -> ShowS # show :: ConfigError -> String # showList :: [ConfigError] -> ShowS # |
A configuration key is a non-empty list of parts. By convention, these parts are separated by dots when written, although dots withing parts are not disallowed.
For writing values easily, consider enabling the QuasiQuotes
language extension
to use key
:
>>>
[key|foo.bar|]
foo.bar
class ConfigValue a where Source #
Values which can be read from a config source must implement this class
Minimal complete definition
Methods
fromConfig :: Value -> Either ConfigError a Source #
prettyValue :: a -> Text Source #
optionally, a function to pretty-print values of this type, used by the
functions of Conftrack.Pretty. If not given, defaults to a
's Show
instance.
default prettyValue :: Show a => a -> Text Source #
Instances
ConfigValue ByteString Source # | |
Defined in Conftrack.Value Methods fromConfig :: Value -> Either ConfigError ByteString Source # prettyValue :: ByteString -> Text Source # | |
ConfigValue ByteString Source # | |
Defined in Conftrack.Value Methods fromConfig :: Value -> Either ConfigError ByteString Source # prettyValue :: ByteString -> Text Source # | |
ConfigValue OsPath Source # | |
Defined in Conftrack.Value Methods fromConfig :: Value -> Either ConfigError OsPath Source # prettyValue :: OsPath -> Text Source # | |
ConfigValue Text Source # | |
Defined in Conftrack.Value | |
ConfigValue Integer Source # | |
Defined in Conftrack.Value Methods fromConfig :: Value -> Either ConfigError Integer Source # prettyValue :: Integer -> Text Source # | |
ConfigValue Bool Source # | |
Defined in Conftrack.Value | |
ConfigValue Int Source # | |
Defined in Conftrack.Value | |
ConfigValue a => ConfigValue (Maybe a) Source # | |
Defined in Conftrack.Value Methods fromConfig :: Value -> Either ConfigError (Maybe a) Source # prettyValue :: Maybe a -> Text Source # |
Constructors
forall a.ConfigValue a => Origin a Text |
withString :: (ByteString -> Either ConfigError a) -> Value -> Either ConfigError a Source #