| 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
- addStringBinding :: MonadThrow m => (String, String) -> Environment -> m Environment
- insertPositionalArguments :: [Text] -> Environment -> Environment
- type EnvironmentReaderT m a = ReaderT Environment m a
- type MonadEnvironment m = MonadReader Environment m
- runEnvironmentReaderT :: Environment -> EnvironmentReaderT m a -> m a
- askEnvironment :: MonadEnvironment m => m Environment
- localEnvironment :: MonadEnvironment m => (Environment -> Environment) -> m a -> m a
- lookupOrThrow :: (MonadThrow m, MonadEnvironment m) => Text -> m Text
- lookupEither :: MonadEnvironment m => Text -> m (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)
Since: 0.5.62
addStringBinding :: MonadThrow m => (String, String) -> Environment -> m Environment Source #
Insert a value into an Environment.
Since: 0.5.62
insertPositionalArguments :: [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
type EnvironmentReaderT m a = ReaderT Environment m a Source #
A monad transformer providing a MonadReader instance for Environment
Since: 0.5.62
type MonadEnvironment m = MonadReader Environment m Source #
A constraint on a monad m ensuring (read-only) access to an Environment
Since: 0.5.62
runEnvironmentReaderT :: Environment -> EnvironmentReaderT m a -> m a Source #
Run a ReaderT of Environment.
Since: 0.5.62
askEnvironment :: MonadEnvironment m => m Environment Source #
Get the current Environment
Since: 0.5.62
localEnvironment :: MonadEnvironment m => (Environment -> Environment) -> m a -> m a Source #
Run a computation with a modified Environment
Since: 0.5.62
lookupOrThrow :: (MonadThrow m, MonadEnvironment m) => Text -> m 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 :: MonadEnvironment m => Text -> m (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
| 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
| 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 # | |