Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- considerEnv :: (Monad m, FromEnv a) => String -> WithEnvT m (Maybe a)
- considerEnvs :: (Monad m, FromEnv a) => [String] -> WithEnvT m (Maybe a)
- withOptions :: (Monad m, FromEnv option) => Maybe option -> [Option ()] -> WithEnvT m (Maybe option)
- withOption :: (Monad m, FromEnv option) => Maybe option -> Option () -> WithEnvT m (Maybe option)
- withOptionDefault :: (Monad m, FromEnv option) => Maybe option -> Option option -> WithEnvT m option
- withOptionSwitch :: Monad m => Bool -> Option Bool -> WithEnvT m Bool
- class FromEnv a where
- type WithEnv = WithEnvT Identity
- newtype WithEnvT m a = WithEnvT {}
- runWithEnv :: [(String, String)] -> WithEnv a -> Either String a
- runWithEnvT :: [(String, String)] -> WithEnvT m a -> m (Either String a)
Documentation
considerEnv :: (Monad m, FromEnv a) => String -> WithEnvT m (Maybe a) Source #
Lookup a key in the application environment then parse the value
with a FromEnv
instance'
considerEnvs :: (Monad m, FromEnv a) => [String] -> WithEnvT m (Maybe a) Source #
Lookup a list of keys with considerEnv
and return the first
value to parse successfully.
withOptions :: (Monad m, FromEnv option) => Maybe option -> [Option ()] -> WithEnvT m (Maybe option) Source #
Lookup a list of keys with withOption
and return the first
value to parse successfully.
withOption :: (Monad m, FromEnv option) => Maybe option -> Option () -> WithEnvT m (Maybe option) Source #
Given the parse result for an option and the 'Option def' record for that option, query the environment, and then merge the results from the parser and environment.
withOptionDefault :: (Monad m, FromEnv option) => Maybe option -> Option option -> WithEnvT m option Source #
Given the parse result for an option and the 'Option def' record for that option, query the environment, and then merge the results from the parser, environment, and the default.
withOptionSwitch :: Monad m => Bool -> Option Bool -> WithEnvT m Bool Source #
Switches in 'optparse-applicative' have different semantics then
ordinary flags. They are always optional and produce a False
when
absent rather then a Nothing
.
In HGE we give Env Vars a higher precedence then an absent Switch
but the ordinary withEnv
operation expects a Nothing
for an
absent arg parser result.
This function executes with 'withOption Nothing' when the Switch is
absent, otherwise it returns True
.
An alternative solution would be to make Switches return 'Maybe _',
where '_' is an option specific sum type. This would allow us to
use withOptionDefault
directly. Additionally, all fields of
ServeOptionsRaw
would become Maybe
or First
values which
would allow us to write a 'Monoid ServeOptionsRaw' instance for
combing different option sources.
class FromEnv a where Source #
A Read
style parser used for consuming Env Vars and building
ReadM
parsers for 'optparse-applicative'.
Instances
The monadic context for querying Env Vars.
Instances
MonadTrans WithEnvT Source # | |
Defined in Hasura.Server.Init.Env | |
Monad m => MonadError String (WithEnvT m) Source # | |
Defined in Hasura.Server.Init.Env throwError :: String -> WithEnvT m a # catchError :: WithEnvT m a -> (String -> WithEnvT m a) -> WithEnvT m a # | |
Monad m => Monad (WithEnvT m) Source # | |
Functor m => Functor (WithEnvT m) Source # | |
Monad m => Applicative (WithEnvT m) Source # | |
Defined in Hasura.Server.Init.Env | |
MonadIO m => MonadIO (WithEnvT m) Source # | |
Defined in Hasura.Server.Init.Env | |
MFunctor WithEnvT Source # | |
Defined in Hasura.Server.Init.Env | |
Monad m => MonadReader [(String, String)] (WithEnvT m) Source # | |