Skip to Content
i documentation
Standard library referenceModules

std/bool

Functions for the built-in type Bool { True False }.

&& and || are operators and may not be used as values; and and or are the same as functions, for example for list.fold. They do both sides, because the arguments of a call are always worked out.

not

False for True, and True for False.

not = (a : Bool) -> Bool { core.not(a) }

and

True when both are True.

and = (a : Bool, b : Bool) -> Bool { a && b }

or

True when one or both are True.

or = (a : Bool, b : Bool) -> Bool { a || b }

xor

True when exactly one is True.

xor = (a : Bool, b : Bool) -> Bool { a != b }

nand

False when both are True.

nand = (a : Bool, b : Bool) -> Bool { core.not(a && b) }

nor

True when both are False.

nor = (a : Bool, b : Bool) -> Bool { core.not(a || b) }

exclusive_nor

True when both are the same.

exclusive_nor = (a : Bool, b : Bool) -> Bool { a == b }

to_string

"True" or "False".

to_string = (bool : Bool) -> String {

to_int

1 for True and 0 for False.

to_int = (bool : Bool) -> Int { bool |> (True) { 1 } | (False) { 0 } }

compare

Compares two bools, with False < True.

compare = (a : Bool, with : Bool) -> Order {

guard

Gives return when when is True, and the value of otherwise() when not. It is used to end early:

bool.guard(n < 0, "negative", () { "positive" })
guard = <A, N>(when : Bool, return : A, otherwise : () <- N -> A) -> A {

lazy_guard

Like guard, but the value for True is made by a function too.

lazy_guard = <A, N>(