Closed olympichek closed 4 months ago
Is it that the Result
and Option
monads are corresponded exactly to the Result
& Option
type in Rust?
Is it that the
Result
andOption
monads are corresponded exactly to theResult
&Option
type in Rust?
Yes, that's the idea
This pull request implements various updates of monads and lenses for simulations:
Error
monad which was used previously,Panic
andResult
monads are defined to model different kinds of error handling within Rust programs. To complement theResult
monad,Option
monad is also definedM?
forOption
monad,M??
forResult
monad andM!?
forPanic
monadLensOption
. For this lens,read
andwrite
operations can fail by returningNone
value. Thelift
function for this lens allows to lift state monad computation that returnsoption
valueLensPanic
. For this lens,read
andwrite
operations can fail with a panic. If within thelift
function one of these operations fail, than the result would be the computation that panicsNotations
module that re-exports all notations is also addedAdditionally, REVM stack operations are rewritten using
LensPanic
. This provides an example of how lenses can be used to represent subpointers (mutable references). In this example,LensPanic
is necessary, as the lens is used to representtop_unsafe
operation, which fails with a panic when called on an empty stack.