.. title:: GenMonad lisa.fuzz.GenMonad ================== .. autoclass:: lisa.fuzz::GenMonad :no-members: :no-inherited-members: :no-undoc-members: :no-private-members: :no-special-members: .. rubric:: Attributes .. list-table:: :align: left * - :attr:`~lisa.monad.State.__slots__` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State .. rubric:: Properties .. list-table:: :align: left * - :attr:`~lisa.monad.State.f` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State State-transforming function of type ``state -> (value, new_state)``. * - :attr:`~lisa.utils.Loggable.logger` :sup:`inherited` - .. withrefctx:: :module: lisa.utils :class: lisa.utils.Loggable Convenience short-hand for ``self.get_logger()``. .. rubric:: Methods .. list-table:: :align: left * - :meth:`~lisa.fuzz.GenMonad.bind` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State Takes a monadic value Monad[A], a function that takes an A and returns Monad[B], and returns a Monad[B]. * - :meth:`~lisa.fuzz.GenMonad.make_state` - .. withrefctx:: :module: lisa.fuzz :class: lisa.fuzz.GenMonad Initialize the RNG state with either an rng or a seed. * - :meth:`~lisa.monad.Monad.__await__` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad._MonadBase * - :meth:`~lisa.monad.StateDiscard.__call__` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.StateDiscard Allow calling monadic values to run the state-transforming function, with the initial state provided by :meth:`State.make_state`. * - :meth:`~lisa.monad.MonadTrans.do` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.MonadTrans Decorate a coroutine function so that ``awaits`` gains the powers of the monad. * - :meth:`~lisa.monad.State.from_f` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State Build a monadic value out of a state modifying function of type ``state -> (value, new_state)``. * - :meth:`~lisa.utils.Loggable.get_logger` :sup:`inherited` - .. withrefctx:: :module: lisa.utils :class: lisa.utils.Loggable Provides a :class:`logging.Logger` named after ``cls``. * - :meth:`~lisa.monad.State.get_state` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State Returns a monadic value returning the current state. * - :meth:`~lisa.monad.State.hoist` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State Lift a monadic value ``m`` by one level in the stack, i.e.: Given a stack for 3 transformers ``T1(T2(T3(Identity)))``, a value ``m = T2(Identity).pure(42)``. we have ``T2.hoist(m, T3.pure) == T2(T3(Identity)).pure(42)``. * - :meth:`~lisa.monad.Monad.join` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.Monad Takes a monadic value Monad[Monad[A]], and returns a Monad[A]. * - :meth:`~lisa.monad.State.lift` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State Lift a monadic value ``m`` by one level in the stack, i.e.: Given a stack for 3 transformers ``T1(T2(T3(Identity)))``, a value ``m = T3(Identity).pure(42)``. we have ``T2.lift(m) == T2(T3(Identity)).pure(42)``. * - :meth:`~lisa.utils.Loggable.log_locals` :sup:`inherited` - .. withrefctx:: :module: lisa.utils :class: lisa.utils.Loggable Debugging aid: log the local variables of the calling function. * - :meth:`~lisa.monad.Monad.map` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.Monad Takes a monadic value Monad[A], a function that takes an A and returns B, and returns a Monad[B]. * - :meth:`~lisa.monad.State.modify_state` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State Returns a monadic value applying ``f`` on the current state, setting the new state and then returning it. * - :meth:`~lisa.monad.MonadTrans.pure` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.MonadTrans Turn a regular value of type ``A`` into a monadic value of type ``Monad[A]``. * - :meth:`~lisa.monad.State.set_state` :sup:`inherited` - .. withrefctx:: :module: lisa.monad :class: lisa.monad.State Returns a monadic value setting the current state and returning the old one. Attributes ---------- .. autoattribute:: lisa.fuzz::GenMonad.__slots__ Properties ---------- .. autoproperty:: lisa.fuzz::GenMonad.f .. autoproperty:: lisa.fuzz::GenMonad.logger Methods ------- .. automethod:: lisa.fuzz::GenMonad.bind .. automethod:: lisa.fuzz::GenMonad.make_state .. automethod:: lisa.fuzz::GenMonad.__await__ .. automethod:: lisa.fuzz::GenMonad.__call__ .. automethod:: lisa.fuzz::GenMonad.do .. automethod:: lisa.fuzz::GenMonad.from_f .. automethod:: lisa.fuzz::GenMonad.get_logger .. automethod:: lisa.fuzz::GenMonad.get_state .. automethod:: lisa.fuzz::GenMonad.hoist .. automethod:: lisa.fuzz::GenMonad.join .. automethod:: lisa.fuzz::GenMonad.lift .. automethod:: lisa.fuzz::GenMonad.log_locals .. automethod:: lisa.fuzz::GenMonad.map .. automethod:: lisa.fuzz::GenMonad.modify_state .. automethod:: lisa.fuzz::GenMonad.pure .. automethod:: lisa.fuzz::GenMonad.set_state