env-guard-effectful-0.1: Environment effects
Safe HaskellNone
LanguageGHC2021

Effectful.Environment.Guard.Static

Synopsis

Effect

data EnvGuard (a :: Type -> Type) b Source #

Static effect for EnvGuard.

Since: 0.1

Instances

Instances details
type DispatchOf EnvGuard Source # 
Instance details

Defined in Effectful.Environment.Guard.Static

data StaticRep EnvGuard Source # 
Instance details

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

data ExpectEnv Source #

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

Instances

Instances details
Show ExpectEnv

Since: env-guard-0.1.1

Instance details

Defined in System.Environment.Guard.Lifted

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

guardOrElse Source #

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

guardOrElse' Source #

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

Checking environment variable predicate

guardPredicate :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> (String -> Bool) -> Eff es a -> Eff es (Maybe a) Source #

Since: 0.1

guardPredicate_ :: forall (es :: [Effect]) a. (EnvGuard :> es, HasCallStack) => String -> (String -> Bool) -> Eff es a -> Eff es () Source #

Since: 0.1