aboutsummaryrefslogtreecommitdiff
path: root/control/monad/state.scm
diff options
context:
space:
mode:
Diffstat (limited to 'control/monad/state.scm')
-rw-r--r--control/monad/state.scm19
1 files changed, 10 insertions, 9 deletions
diff --git a/control/monad/state.scm b/control/monad/state.scm
index f7190af..b5fefe3 100644
--- a/control/monad/state.scm
+++ b/control/monad/state.scm
@@ -2,9 +2,8 @@
#:use-module (oop goops)
#:use-module (ice-9 match)
#:use-module (control monad)
- #:use-module (data functor)
#:export (return-state run-state get put modify)
- #:re-export (>>= >> fmap))
+ #:re-export (>>= >> fmap return))
;; Alternative implementation of get.
@@ -49,14 +48,16 @@
((v _)
((proc (f v)) new-st-list)))))
-(define-stateful-method ((>> (a <state>) (b <state>)) st-list-a)
- (let ((st-list-b ((proc a) st-list-a)))
- ((proc b) st-list-b)))
+;; (define-stateful-method ((>> (a <state>) (b <state>)) st-list-a)
+;; (let ((st-list-b ((proc a) st-list-a)))
+;; ((proc b) st-list-b)))
(define-stateful ((return-state v) st-list)
"Sets the return value to v"
(cons v (cdr st-list)))
+(define-method (return (a <state>)) return-state)
+
(define-stateful ((get) st-list)
"Sets the return value of state to st."
(match st-list
@@ -72,10 +73,10 @@
((r s)
(list '() (proc s)))))
-(define-stateful-method ((fmap (f <procedure>) (s <state>)) st-list)
- (match ((proc s) st-list)
- ((r st)
- (list (f r) st))))
+;; (define-stateful-method ((fmap (f <procedure>) (s <state>)) st-list)
+;; (match ((proc s) st-list)
+;; ((r st)
+;; (list (f r) st))))
(define-method (run-state (st <state>) init)
"Exec state with init as starting state value and st."