aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--monad/state.scm6
1 files changed, 2 insertions, 4 deletions
diff --git a/monad/state.scm b/monad/state.scm
index 40c9ff5..c607765 100644
--- a/monad/state.scm
+++ b/monad/state.scm
@@ -77,11 +77,9 @@
"Sets st to v."
(list '() v))
-(define-stateful ((modify proc) st-list)
+(define (modify proc)
"Applies proc to the value stored in state, and stores it back"
- (match st-list
- ((r s)
- (list '() (proc s)))))
+ (>>= (<$> proc (get)) put))
(define-method (run-state (st <state>) init)
"Exec state with init as starting state value and st."