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 sameSBoolsubtype but of the opposite truthinessPython’s
notoperator always returns abool
constants
TRUTHandLIEare the unique truthy and falsySBoolvalues
Flavored Booleans¶
functions
truthyandfalsytake any hashable value called its flavorthey return the unique truthy or falsy
FBoolrespectively of that flavor
Truthy_Falsy Booleans¶
use
TF_Booleans = T_Bool | F_Bool | TF_Boolonly as a typedirectly use
T_Bool,F_Bool,TF_Boolas the type constructorsconstants
ALWAYSandNeverare the uniqueTS_Booltruthy and falsy valuesbut they are distinct subtypes of
TS_Boolfor
TS_Boolwe havetype(ALWAYS) is T_Booltype(NEVER) is F_Bool
while for
boolwe havetype(True) is booltype(False) is bool