//@NO-IMPLICIT-PRELUDE
//! The boolean type.
let { Bool, Ordering } = import! std.types
let { Semigroup } = import! std.semigroup
let { Monoid } = import! std.monoid
let { Group } = import! std.group
let { Eq, Ord } = import! std.cmp
let { Show } = import! std.show
let { id } = import! std.function
/// Boolean 'not'
let not x : Bool -> Bool = if x then False else True
/// Boolean 'exclusive or'
let xor x y : Bool -> Bool -> Bool = if x then not y else y
let conjunctive =
let semigroup : Semigroup Bool = {
append = \x y -> x && y
}
let monoid : Monoid Bool = {
semigroup = semigroup,
empty = True,
}
{ semigroup, monoid }
let disjunctive =
let semigroup : Semigroup Bool = {
append = \x y -> x || y
}
let monoid : Monoid Bool = {
semigroup = semigroup,
empty = False,
}
{ semigroup, monoid }
let exclusive =
let semigroup : Semigroup Bool = { append = xor }
let monoid : Monoid Bool = {
semigroup = semigroup,
empty = False,
}
let group : Group Bool = {
monoid = monoid,
inverse = id,
}
{ semigroup, monoid, group }
let eq : Eq Bool = {
(==) = \l r -> if l then r else not r
}
let ord : Ord Bool = {
eq = eq, compare = \l r -> if l then if r then EQ else GT else LT
}
let show : Show Bool = {
show = \x -> if x then "True" else "False"
}
{
Bool,
not,
xor,
conjunctive,
disjunctive,
exclusive,
eq,
ord,
show,
}