diff options
author | Nao Pross <np@0hm.ch> | 2024-05-09 12:51:57 +0200 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2024-05-09 12:51:57 +0200 |
commit | c44b3931c0be15146866fad4e8915468bd49c9b7 (patch) | |
tree | 1081d4c71cec22a7318194e2454fa23afa4b3d6c | |
parent | Fix bug in __str__ of StateMonad (diff) | |
download | polymatrix-c44b3931c0be15146866fad4e8915468bd49c9b7.tar.gz polymatrix-c44b3931c0be15146866fad4e8915468bd49c9b7.zip |
Add few comments to FromStateMonad
-rw-r--r-- | polymatrix/expression/mixins/fromstatemonad.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/polymatrix/expression/mixins/fromstatemonad.py b/polymatrix/expression/mixins/fromstatemonad.py index 216b160..a5970b1 100644 --- a/polymatrix/expression/mixins/fromstatemonad.py +++ b/polymatrix/expression/mixins/fromstatemonad.py @@ -25,12 +25,19 @@ class FromStateMonadMixin(ExpressionBaseMixin): @override def apply(self, state: ExpressionStateMixin) -> tuple[ExpressionStateMixin, PolyMatrixMixin]: state, expr = self.monad.apply(state) + # Case when monad wraps function + # f: ExpressionState -> (State, Expression) if isinstance(expr, Expression): return expr.underlying.apply(state) + # Case when monad wraps function + # f: ExpressionState -> (State, M) + # where M is a mixin class elif isinstance(expr, ExpressionBaseMixin): return expr.apply(state) + # Case when monad wraps function + # f: ExpressionState -> (State, PolyMatrix) elif isinstance(expr, PolyMatrixMixin): return state, expr |