Skip to content

aivi.bool ​

Boolean utilities for AIVI. These functions complement the built-in and, or, and bool branching operators with named combinators for common logical patterns.

aivi
use aivi.bool (
    not
    xor
    implies
    both
    either
    neither
    fromInt
)

At a glance ​

FunctionTypeUse it for
notBool -> BoolNegate a boolean
xorBool -> Bool -> BoolCheck whether exactly one side is true
impliesBool -> Bool -> BoolExpress logical implication
bothBool -> Bool -> BoolNamed and
eitherBool -> Bool -> BoolNamed or
neitherBool -> Bool -> BoolCheck whether both sides are false
fromIntInt -> BoolTreat 0 as false and everything else as true

not ​

Negates a boolean value.

aivi
use aivi.bool (not)

value inactive = not True
// False

xor ​

Returns True if exactly one of the two arguments is True (exclusive or).

aivi
use aivi.bool (xor)

type Bool -> Bool -> Bool
func toggleChanged = previous current =>
    xor previous current

implies ​

Logical implication: implies a b is False only when a is True and b is False.

aivi
use aivi.bool (implies)

type Bool -> Bool -> Bool
func checkRule = hasPermission canAccess =>
    implies hasPermission canAccess

both ​

Returns True if both arguments are True. Equivalent to a and b.

aivi
use aivi.bool (both)

type Bool -> Bool -> Bool
func isAdminAndActive = isAdmin isActive =>
    both isAdmin isActive

either ​

Returns True if at least one argument is True. Equivalent to a or b.

aivi
use aivi.bool (either)

type Bool -> Bool -> Bool
func canProceed = hasTokenA hasTokenB =>
    either hasTokenA hasTokenB

neither ​

Returns True only if both arguments are False.

aivi
use aivi.bool (neither)

type Bool -> Bool -> Bool
func isSilent = isPlaying isPaused =>
    neither isPlaying isPaused

fromInt ​

Converts an integer to a boolean: 0 becomes False, any other value becomes True.

aivi
use aivi.bool (fromInt)

type Int -> Bool
func hasFlags =
  |> fromInt

(c) 2026 by Andreas Herd