Safe Haskell | None |
---|---|
Language | GHC2021 |
Effectful.Environment.Guard.Static
Synopsis
- data EnvGuard (a :: Type -> Type) b
- runEnvGuard :: forall (es :: [Effect]) a. IOE :> es => Eff (EnvGuard ': es) a -> Eff es a
- data ExpectEnv
- withGuard :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> ExpectEnv -> Eff es a -> Eff es (Maybe a)
- withGuard_ :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> ExpectEnv -> Eff es a -> Eff es ()
- guardOrElse :: forall (es :: [Effect]) a e. (EnvGuard :> es, HasCallStack) => String -> ExpectEnv -> Eff es a -> Eff es e -> Eff es (Either e a)
- guardOrElse' :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> ExpectEnv -> Eff es a -> Eff es a -> Eff es a
- guardSet :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> Eff es a -> Eff es (Maybe a)
- guardSet_ :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> Eff es a -> Eff es ()
- guardEquals :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> String -> Eff es a -> Eff es (Maybe a)
- guardEquals_ :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> String -> Eff es a -> Eff es ()
- guardPredicate :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> (String -> Bool) -> Eff es a -> Eff es (Maybe a)
- guardPredicate_ :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> (String -> Bool) -> Eff es a -> Eff es ()
Effect
data EnvGuard (a :: Type -> Type) b Source #
Static effect for EnvGuard
.
Since: 0.1
Instances
type DispatchOf EnvGuard Source # | |
Defined in Effectful.Environment.Guard.Static | |
data StaticRep EnvGuard Source # | |
Defined in Effectful.Environment.Guard.Static |
Handler
runEnvGuard :: forall (es :: [Effect]) a. IOE :> es => Eff (EnvGuard ': es) a -> Eff es a Source #
Runs an EnvGuard effect.
Since: 0.1
High level combinators
The expectation for an environment variable lookup.
Since: env-guard-0.1.1
Constructors
ExpectEnvSet | Expect that the environment variable is set (i.e. contents can be anything). Since: env-guard-0.1.1 |
ExpectEnvEquals String | Expect that the environment variable is set and the contents equals the string. This is case-insensitive. Since: env-guard-0.1.1 |
ExpectEnvPredicate (String -> Bool) | Expect that the environment variable is set and its contents satisfies the predicate. Since: env-guard-0.1.1 |
withGuard :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> ExpectEnv -> Eff es a -> Eff es (Maybe a) Source #
Since: 0.1
withGuard_ :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> ExpectEnv -> Eff es a -> Eff es () Source #
Since: 0.1
Arguments
:: forall (es :: [Effect]) a e. (EnvGuard :> es, HasCallStack) | |
=> String | The environment variable. |
-> ExpectEnv | The expectation. |
-> Eff es a | The action to run if the expectation succeeds. |
-> Eff es e | The action to run if the expectation fails. |
-> Eff es (Either e a) | The result. |
Since: 0.1
Arguments
:: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) | |
=> String | The environment variable. |
-> ExpectEnv | The expectation. |
-> Eff es a | The action to run if the expectation succeeds. |
-> Eff es a | The action to run if the expectation fails. |
-> Eff es a | The result. |
Since: 0.1
Low level functions
Checking environment variable is set
guardSet :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> Eff es a -> Eff es (Maybe a) Source #
Since: 0.1
guardSet_ :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> Eff es a -> Eff es () Source #
Since: 0.1
Checking environment variable match
guardEquals :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> String -> Eff es a -> Eff es (Maybe a) Source #
Since: 0.1
guardEquals_ :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> String -> Eff es a -> Eff es () Source #
Since: 0.1