lisa.wlgen.rta.RTAMonad#
- class lisa.wlgen.rta.RTAMonad(f)[source]#
Bases:
StateDiscard
Monad from derived from
lisa.monad.StateDiscard
used to defineRTAPhaseBase
in a more natural way.If the function returns
None
, the return value will be replaced by theRTAPhaseBase
created while executing the function, with all the currently active properties applied to it.See also
See the
task_factory()
decorator to be able to mix these actions with the ones fromlisa.fuzz.Gen
.Attributes
__slots__
inheritedProperties
f
inheritedState-transforming function of type
state -> (value, new_state)
.Methods
Takes a monadic value Monad[A], a function that takes an A and returns Monad[B], and returns a Monad[B].
Create a fresh instance of
RTAMonad._State
.__await__()
inherited__call__()
inheritedAllow calling monadic values to run the state-transforming function, with the initial state provided by
State.make_state()
.do()
inheritedDecorate a coroutine function so that
awaits
gains the powers of the monad.from_f()
inheritedBuild a monadic value out of a state modifying function of type
state -> (value, new_state)
.get_state()
inheritedReturns a monadic value returning the current state.
hoist()
inheritedLift a monadic value
m
by one level in the stack, i.e.: Given a stack for 3 transformersT1(T2(T3(Identity)))
, a valuem = T2(Identity).pure(42)
. we haveT2.hoist(m, T3.pure) == T2(T3(Identity)).pure(42)
.join()
inheritedTakes a monadic value Monad[Monad[A]], and returns a Monad[A].
lift()
inheritedLift a monadic value
m
by one level in the stack, i.e.: Given a stack for 3 transformersT1(T2(T3(Identity)))
, a valuem = T3(Identity).pure(42)
. we haveT2.lift(m) == T2(T3(Identity)).pure(42)
.map()
inheritedTakes a monadic value Monad[A], a function that takes an A and returns B, and returns a Monad[B].
modify_state()
inheritedReturns a monadic value applying
f
on the current state, setting the new state and then returning it.pure()
inheritedTurn a regular value of type
A
into a monadic value of typeMonad[A]
.set_state()
inheritedReturns a monadic value setting the current state and returning the old one.
Attributes#
- RTAMonad.__slots__ = ('_f',)#
Properties#
- property RTAMonad.f#
Inherited property, see
lisa.monad.State.f
State-transforming function of type
state -> (value, new_state)
.
Methods#
- RTAMonad.bind(continuation)#
Takes a monadic value Monad[A], a function that takes an A and returns Monad[B], and returns a Monad[B].
Note
It is allowed to return a
_TailCall
instance.
- RTAMonad.__await__()#
Inherited method, see
lisa.monad.Monad.__await__()
- RTAMonad.__call__(*args, **kwargs)#
Inherited method, see
lisa.monad.StateDiscard.__call__()
Allow calling monadic values to run the state-transforming function, with the initial state provided by
State.make_state()
.
- classmethod RTAMonad.do(f)#
Inherited method, see
lisa.monad.MonadTrans.do()
Decorate a coroutine function so that
awaits
gains the powers of the monad.
- classmethod RTAMonad.from_f(f)#
Inherited method, see
lisa.monad.State.from_f()
Build a monadic value out of a state modifying function of type
state -> (value, new_state)
.
- classmethod RTAMonad.get_state()#
Inherited method, see
lisa.monad.State.get_state()
Returns a monadic value returning the current state.
- classmethod RTAMonad.hoist(self, nat)#
Inherited method, see
lisa.monad.State.hoist()
Lift a monadic value
m
by one level in the stack, i.e.: Given a stack for 3 transformersT1(T2(T3(Identity)))
, a valuem = T2(Identity).pure(42)
. we haveT2.hoist(m, T3.pure) == T2(T3(Identity)).pure(42)
.
- classmethod RTAMonad.join(self)#
Inherited method, see
lisa.monad.Monad.join()
Takes a monadic value Monad[Monad[A]], and returns a Monad[A].
- classmethod RTAMonad.lift(m)#
Inherited method, see
lisa.monad.State.lift()
Lift a monadic value
m
by one level in the stack, i.e.: Given a stack for 3 transformersT1(T2(T3(Identity)))
, a valuem = T3(Identity).pure(42)
. we haveT2.lift(m) == T2(T3(Identity)).pure(42)
.
- classmethod RTAMonad.map(self, f)#
Inherited method, see
lisa.monad.Monad.map()
Takes a monadic value Monad[A], a function that takes an A and returns B, and returns a Monad[B].
- classmethod RTAMonad.modify_state(f)#
Inherited method, see
lisa.monad.State.modify_state()
Returns a monadic value applying
f
on the current state, setting the new state and then returning it.
- classmethod RTAMonad.pure(x)#
Inherited method, see
lisa.monad.MonadTrans.pure()
Turn a regular value of type
A
into a monadic value of typeMonad[A]
.
- classmethod RTAMonad.set_state(new)#
Inherited method, see
lisa.monad.State.set_state()
Returns a monadic value setting the current state and returning the old one.