Usage¶
How to installing the package¶
Install the project into your Python environment:
$ pip install pythonic-fp-booleans
Importing the module¶
Import package booleans classes, functions and constants into your code.
from pythonic_fp.booleans.subtypable SBool, snot, TRUTH, LIE
from pythonic_fp.booleans.subtypes.flavored FBool, truthy, falsy
from pythonic_fp.booleans.subtypes.truthy_falsy TF_Booleans
from pythonic_fp.booleans.subtypes.truthy_falsy TF_Bool, T_Bool, F_Bool
from pythonic_fp.booleans.subtypes.truthy_falsy ALWAYS, NEVER_EVER
Best practices¶
Subtypable Booleans¶
use the
~
to return the sameSBool
subtype but of the opposite truthinessPython’s
not
operator always returns abool
constants
TRUTH
andLIE
are the unique truthy and falsySBool
values
Flavored Booleans¶
functions
truthy
andfalsy
take any hashable value called its flavorthey return the unique truthy or falsy
FBool
respectively of that flavor
Truthy_Falsy Booleans¶
use
TF_Booleans = T_Bool | F_Bool | TF_Bool
only as a typedirectly use
T_Bool
,F_Bool
,TF_Bool
as the type constructorsconstants
ALWAYS
andNever
are the unique truthy and falsy valuesbut they have distinct distinct types
we have
type(ALWAYS) is T_Bool
andtype(NEVER) is F_Bool
while
type(True) is bool
andtype(False) is bool