flavored¶
- final class pythonic_fp.booleans.flavored.FBool¶
Bases:
SBoolFavored Booleans
When different flavors of the truth matter. Each FBool is an SBool subtype corresponding to a hashable flavor.
Warning
Combining FBool instances of different flavors with bitwise operators will result in a runtime ValueError exception.
- static __new__(cls, witness: object, flavor: Hashable) Self¶
new
Traditional singleton pattern but with a ClassVar dict to store the for truthy or falsy singleton for each hashable flavor.
- param witness:
Determines truthiness of the FBool instance returned.
- param flavor:
The flavor of FBool to created.
- returns:
The truthy or falsy FBool instance of a particular flavor.
- __init__(witness: object, flavor: Hashable) None¶
initialize
Let the flavored boolean know its flavor.
- param witness:
Determines truthiness of the FBool instance returned.
- param flavor:
The flavor of FBool to created.
- type flavor:
H: Hashable
- returns:
The truthy or falsy FBool instance of a particular flavor.
- raises ValueError:
If different flavors compared with bitwise operators.
- __and__(other: int) int¶
Return self&value.
- __or__(other: int) int¶
Return self|value.
- __xor__(other: int) int¶
Return self^value.
- __repr__() str¶
- __str__() str¶
- flavor() Hashable¶
flavor
Get the flavor of the FBool, a hashable value.
- returns:
The flavor.