diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2018-11-13 00:36:09 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2018-11-13 00:38:38 +0100 |
commit | f1225201c9ded1078ef1f98fbf4969a8480d3b38 (patch) | |
tree | dfca9a64349927b9daf585939f3494b5d43742a6 /control/monad/state.scm | |
parent | Add define-stateful-method. (diff) | |
download | scheme-monad-f1225201c9ded1078ef1f98fbf4969a8480d3b38.tar.gz scheme-monad-f1225201c9ded1078ef1f98fbf4969a8480d3b38.tar.xz |
Add simple stateful stack implementation.
Diffstat (limited to 'control/monad/state.scm')
-rw-r--r-- | control/monad/state.scm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/control/monad/state.scm b/control/monad/state.scm index e369d5d..1097567 100644 --- a/control/monad/state.scm +++ b/control/monad/state.scm @@ -2,9 +2,12 @@ #:use-module (oop goops) #:use-module (ice-9 match) #:use-module (control monad) - #:export (make-state return-state - get put - run-state) + #:export (return-state run-state + get put + ;; TODO + ;; should these even be exported? + define-stateful + define-stateful-method) #:re-export (>>= >>)) @@ -28,6 +31,12 @@ "Creates a state object from a State procedure" (make <state> #:proc proc)) +;;; Define a procedure which is in the state monad. This means that it takes a +;;; state list as a curried argument, and it's return is wrappen in a <state> +;;; object. +;;; It's fully possible to create stateful objects without these macros, but it's +;;; ill adviced since that would just be boilerplate. + (define-syntax-rule (define-stateful ((proc args ...) st) body ...) (define (proc args ...) (make-state |