Std.Bool (Cure Standard Library v0.37.2)

View Source

Booleans as a real inductive type.

Bool is False | True. The @builtin(:bool) decorator marks this as the canonical Bool the kernel constructs for primitive comparison/connective results and the general :case recursor eliminates (retiring the bespoke bool_elim primitive). Erasure lowers its constructors to native BEAM atoms false/true.

Examples

use Std.Bool

`not`(True())                  # => False()
`and`(True(), False())         # => False()
`or`(False(), True())          # => True()
`eq`(True(), True())           # => True()
`ne`(True(), False())          # => True()

Summary

Functions

Short-circuiting conjunction. and(False(), b) is False() without evaluating b; and(True(), b) is b.

Boolean equality: True() when both operands agree.

Boolean inequality: True() when the operands differ.

Boolean connectives, defined by case-elimination on the inductive Bool (retiring the kernel :and/:or/:not primitives). On open terms they reduce definitionally (e.g. and(True(), b) ≡ b); a saturated application still lowers to the native BEAM boolean op at codegen.

Short-circuiting disjunction. or(True(), b) is True() without evaluating b; or(False(), b) is b.

Types

enum Bool

 enum Bool
   False
   True

Functions

and(a: Bool, b: Bool) -> Bool

 fn and(a: Bool, b: Bool) -> Bool

Short-circuiting conjunction. and(False(), b) is False() without evaluating b; and(True(), b) is b.

eq(a: Bool, b: Bool) -> Bool

 fn eq(a: Bool, b: Bool) -> Bool

Boolean equality: True() when both operands agree.

ne(a: Bool, b: Bool) -> Bool

 fn ne(a: Bool, b: Bool) -> Bool

Boolean inequality: True() when the operands differ.

not(a: Bool) -> Bool

 fn not(a: Bool) -> Bool

Boolean connectives, defined by case-elimination on the inductive Bool (retiring the kernel :and/:or/:not primitives). On open terms they reduce definitionally (e.g. and(True(), b) ≡ b); a saturated application still lowers to the native BEAM boolean op at codegen.

Logical negation: True() becomes False() and vice versa.

or(a: Bool, b: Bool) -> Bool

 fn or(a: Bool, b: Bool) -> Bool

Short-circuiting disjunction. or(True(), b) is True() without evaluating b; or(False(), b) is b.