gond
🔠 Multi-branch conditional expressions for Gleam
Types
Represents a condition that can be evaluated lazily or eagerly,
pub opaque type Condition
Represents a condition that can be evaluated lazily or eagerly,
pub opaque type Consequence(a)
Functions
pub fn cond(
branches branches: List(Branch(a)),
default alternative_fun: fn() -> a,
) -> a
Executes a list of branches and returns the consequence of the first branch that evaluates to true.
If no branch evaluates to true, the default alternative function is executed.
pub fn return(
on condition: Condition,
consequence consequence: a,
) -> Branch(a)
Sets a literal consequence to return if a previous condition evaludated to true.
pub fn run(
on condition: Condition,
consequence consequence_fun: fn() -> a,
) -> Branch(a)
Sets a consequence to run if a previous condition evaludated to true.
pub fn when(given condition_fun: fn() -> Bool) -> Condition
Creates a condition that evaluates to true if the given function returns true.