Monad
- class fpylib.functors.monad.Monad(value: Optional[fpylib.types._T] = None)[source]
This is a implementation of the Monad law: - Unit or Return . - Bind (>>=) or (>>) here.
- bind(func: Callable[[fpylib.types._T], fpylib.types._S]) fpylib.functors.monad.Monad[fpylib.types._S][source]
Return a Monad with the result of the given function evaluated with the value of the Monad.
- Parameters
func – The function to evaluate with the value of the Monad.
- Returns
A Monad with the result of the given function evaluated with the value of the Monad.
- unit(value: fpylib.types._T) fpylib.functors.monad.Monad[fpylib.types._T][source]
Return a Monad with the given value.
- Parameters
value – The value to return.
- Returns
A Monad with the given value.
- fpylib.functors.monad.unit(m: fpylib.functors.monad.Monad, value: fpylib.types._T) fpylib.functors.monad.Monad[fpylib.types._T][source]
The unit function for the Monad.
- Parameters
m – The Monad.
value – The value to be wrapped in the Monad.
- Returns
The Monad with the value.
- fpylib.functors.monad.unitifier(m: fpylib.functors.monad.Monad, conditioner: Optional[Callable[[Callable[[...], fpylib.types._T]], Callable[[...], fpylib.functors.monad.Monad[fpylib.types._T]]]] = None) Callable[[Callable[[...], fpylib.types._T]], Callable[[...], fpylib.functors.monad.Monad[fpylib.types._T]]][source]
Return a decorator that wraps the given function in a Monad. :param m: The Monad. :type m: Monad :param conditioner: A function that takes a function and returns a function that return a Monad. :type conditioner: Callable[[Callable[…, T]], Callable[…, Monad[T]]] :return: A decorator that wraps the given function in a Monad. :rtype: Callable[[Callable[…, T]], Callable[…, Monad[T]]]