Bool package:ghc-internal
The
Bool type and related functions.
Basic operations on type-level Booleans.
Case analysis for the
Bool type.
bool f t p
evaluates to
f when
p is
False, and evaluates
to
t when
p is
True.
This is equivalent to
if p then t else f; that is, one can
think of it as an if-then-else construct with its arguments reordered.
Examples
Basic usage:
>>> bool "foo" "bar" True
"bar"
>>> bool "foo" "bar" False
"foo"
Confirm that
bool f t p and
if p then t else
f are equivalent:
>>> let p = True; f = "bar"; t = "foo"
>>> bool f t p == if p then t else f
True
>>> let p = False
>>> bool f t p == if p then t else f
True
Convert a Haskell
Bool to its numeric representation
Convert a Boolean in numeric representation to a Haskell value