From c44b3931c0be15146866fad4e8915468bd49c9b7 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Thu, 9 May 2024 12:51:57 +0200 Subject: Add few comments to FromStateMonad --- polymatrix/expression/mixins/fromstatemonad.py | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- cgit v1.2.1