| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
B9.Environment
Description
An Environment contains textual key value pairs, relavant for string template
substitution.
The variables are passed to the B9 build either via command line, OS environment variables or configuration file.
Since: 0.5.62
Synopsis
- data Environment
- fromStringPairs :: [(String, String)] -> Environment
- addBinding :: Member ExcB9 e => (Text, Text) -> Environment -> Eff e Environment
- addStringBinding :: Member ExcB9 e => (String, String) -> Environment -> Eff e Environment
- addLocalStringBinding :: (Member EnvironmentReader e, Member ExcB9 e) => (String, String) -> Eff e a -> Eff e a
- addPositionalArguments :: [Text] -> Environment -> Environment
- addLocalPositionalArguments :: Member EnvironmentReader e => [String] -> Eff e a -> Eff e a
- type EnvironmentReader = Reader Environment
- hasKey :: Member EnvironmentReader e => Text -> Eff e Bool
- runEnvironmentReader :: Environment -> Eff (EnvironmentReader ': e) a -> Eff e a
- askEnvironment :: Member EnvironmentReader e => Eff e Environment
- localEnvironment :: Member EnvironmentReader e => (Environment -> Environment) -> Eff e a -> Eff e a
- lookupOrThrow :: '[ExcB9, EnvironmentReader] <:: e => Text -> Eff e Text
- lookupEither :: Member EnvironmentReader e => Text -> Eff e (Either KeyNotFound Text)
- data KeyNotFound = MkKeyNotFound Text Environment
- data DuplicateKey = MkDuplicateKey {}
Documentation
data Environment Source #
A map of textual keys to textual values.
Since: 0.5.62
Instances
fromStringPairs :: [(String, String)] -> Environment Source #
Create an Environment from a list of pairs (Strings).
Duplicated entries are ignored.
Since: 0.5.62
addBinding :: Member ExcB9 e => (Text, Text) -> Environment -> Eff e Environment Source #
Insert a key value binding to the Environment.
Throw DuplicateKey if the key already exists, but
the value is not equal to the given value.
Since: 0.5.67
addStringBinding :: Member ExcB9 e => (String, String) -> Environment -> Eff e Environment Source #
Insert Strings into the Environment, see addBinding.
Since: 0.5.62
addLocalStringBinding :: (Member EnvironmentReader e, Member ExcB9 e) => (String, String) -> Eff e a -> Eff e a Source #
Insert a value into an Environment like addStringBinding,
but add it to the environment of the given effect, as in localEnvironment.
Since: 0.5.65
addPositionalArguments :: [Text] -> Environment -> Environment Source #
If environment variables arg_1 .. arg_n are bound
and a list of k additional values are passed to this function,
store them with keys arg_(n+1) .. arg_(n+k).
Note that the Environment contains an index of the next position.
Since: 0.5.62
addLocalPositionalArguments :: Member EnvironmentReader e => [String] -> Eff e a -> Eff e a Source #
Convenient wrapper around addPositionalArguments and localEnvironment.
Since: 0.5.65
type EnvironmentReader = Reader Environment Source #
A monad transformer providing a MonadReader instance for Environment
Since: 0.5.62
hasKey :: Member EnvironmentReader e => Text -> Eff e Bool Source #
A predicate that is satisfied when a key exists in the environment.
Since: 0.5.64
runEnvironmentReader :: Environment -> Eff (EnvironmentReader ': e) a -> Eff e a Source #
Run a ReaderT of Environment.
Since: 0.5.62
askEnvironment :: Member EnvironmentReader e => Eff e Environment Source #
Get the current Environment
Since: 0.5.62
localEnvironment :: Member EnvironmentReader e => (Environment -> Environment) -> Eff e a -> Eff e a Source #
Run a computation with a modified Environment
Since: 0.5.62
lookupOrThrow :: '[ExcB9, EnvironmentReader] <:: e => Text -> Eff e Text Source #
Lookup a key for a value.
throwM a KeyNotFound Exception if no value with the given key exists
in the Environment.
@Since 0.5.62
lookupEither :: Member EnvironmentReader e => Text -> Eff e (Either KeyNotFound Text) Source #
Lookup a key for a value.
Return Either Left KeyNotFound, if no value with the given key exists
in the Environment, or Right the value.
@Since 0.5.62
data KeyNotFound Source #
An Exception thrown by lookupOrThrow indicating that a key does not exist.
@Since 0.5.62
Constructors
| MkKeyNotFound Text Environment |
Instances
| Eq KeyNotFound Source # | |
Defined in B9.Environment | |
| Show KeyNotFound Source # | |
Defined in B9.Environment Methods showsPrec :: Int -> KeyNotFound -> ShowS # show :: KeyNotFound -> String # showList :: [KeyNotFound] -> ShowS # | |
| Exception KeyNotFound Source # | |
Defined in B9.Environment Methods toException :: KeyNotFound -> SomeException # fromException :: SomeException -> Maybe KeyNotFound # displayException :: KeyNotFound -> String # | |
data DuplicateKey Source #
An Exception thrown by addBinding indicating that a key already exists.
@Since 0.5.62
Constructors
| MkDuplicateKey | |
Fields | |
Instances
| Eq DuplicateKey Source # | |
Defined in B9.Environment | |
| Show DuplicateKey Source # | |
Defined in B9.Environment Methods showsPrec :: Int -> DuplicateKey -> ShowS # show :: DuplicateKey -> String # showList :: [DuplicateKey] -> ShowS # | |
| Exception DuplicateKey Source # | |
Defined in B9.Environment Methods toException :: DuplicateKey -> SomeException # fromException :: SomeException -> Maybe DuplicateKey # displayException :: DuplicateKey -> String # | |