| |
- typing.Generic(builtins.object)
-
- Monoid
class Monoid(typing.Generic) |
|
Monoid(*args, **kwds)
Base class for Monoid instances.
To implement a monoid instance, create a sub-class of Monoid and
override the identity_element and addition_operation methods
ensuring that the closure, identity, and associativity laws hold. |
|
- Method resolution order:
- Monoid
- typing.Generic
- builtins.object
Methods defined here:
- __add__(self: Union[ForwardRef('Monoid[T]'), ForwardRef('_MonoidIdentity')], other: Union[ForwardRef('Monoid[T]'), ForwardRef('_MonoidIdentity')]) -> Union[ForwardRef('Monoid[T]'), ForwardRef('_MonoidIdentity')]
- __eq__(self: Union[ForwardRef('_MonoidIdentity'), ForwardRef('Monoid[T]')], other: Union[ForwardRef('_MonoidIdentity'), ForwardRef('Monoid[T]')]) -> bool
- Return self==value.
- __init__(self, value: ~T) -> None
- Initialize self. See help(type(self)) for accurate signature.
- addition_operation(self: Union[ForwardRef('Monoid[T]'), ForwardRef('_MonoidIdentity')], other: Union[ForwardRef('Monoid[T]'), ForwardRef('_MonoidIdentity')]) -> Union[ForwardRef('Monoid[T]'), ForwardRef('_MonoidIdentity')]
- Defines how monoid values are added together.
addition_operation() method is automatically called by
__add__() so monoid values are typically combined using the +
operator and not addition_operation() directly.
This method must be overridden in subclasses of Monoid.
Args:
other: a monoid value of the same type as self.
Returns:
Another monoid value of the same type as self and other.
Static methods defined here:
- identity_element() -> 'Monoid[Any]'
- Returns the identity value for the monoid type.
This method must be overridden in subclasses of Monoid.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- __hash__ = None
- __orig_bases__ = (typing.Generic[~T],)
- __parameters__ = (~T,)
Class methods inherited from typing.Generic:
- __class_getitem__(params) from builtins.type
- __init_subclass__(*args, **kwargs) from builtins.type
- This method is called when a class is subclassed.
The default implementation does nothing. It may be
overridden to extend subclasses.
Static methods inherited from typing.Generic:
- __new__(cls, *args, **kwds)
- Create and return a new object. See help(type) for accurate signature.
| |