From b282f1a92137e2104b96186d05ff6e543eafdf2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 13 Nov 2018 00:18:31 +0100 Subject: run-state, >>=, and >> now correctly defined for . --- control/monad/state.scm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/control/monad/state.scm b/control/monad/state.scm index a8e7775..3ebdcc6 100644 --- a/control/monad/state.scm +++ b/control/monad/state.scm @@ -29,16 +29,18 @@ (make #:proc proc)) (define-method (>>= (st ) f) - (lambda (st-list) - (let ((new-st-list ((proc st) st-list))) - (match new-st-list - ((v _) - ((proc (f v)) new-st-list)))))) + (make-state + (lambda (st-list) + (let ((new-st-list ((proc st) st-list))) + (match new-st-list + ((v _) + ((proc (f v)) new-st-list))))))) (define-method (>> (a ) (b )) - (lambda (st-list-a) - (let ((st-list-b ((proc a) st-list-a))) - ((proc b) st-list-b)))) + (make-state + (lambda (st-list-a) + (let ((st-list-b ((proc a) st-list-a))) + ((proc b) st-list-b))))) (define-syntax define-stateful (syntax-rules () @@ -61,7 +63,7 @@ "Sets st to v." (list '() v)) -(define-method (run-state st-proc init) +(define-method (run-state (st ) init) "Exec state with init as starting state value and st." - (st-proc (list init init))) + ((proc st) (list init init))) -- cgit v1.2.3