diff options
Diffstat (limited to 'test2.lux')
-rw-r--r-- | test2.lux | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -388,15 +388,6 @@ (lambda [state] (#Ok [state state]))) -(def monadic-dup - (exec [foo get-state - bar get-state - baz (return 1000)] - (return (+ (+ foo bar) baz)))) - -(def (run-state monad state) - (monad state)) - (def list-map #Nil) (def (put key val map) @@ -424,6 +415,25 @@ [?key ?val] (fold concat "" (list "#" ?key " " (show ?val))))) +(def (within slot monad) + (lambda [state] + (let =return (monad (get slot state)) + (case =return + (#Ok ?state ?value) + (#Ok (put slot ?state state) ?value) + + _ + =return)))) + +(def monadic-dup + (exec [foo get-state + bar get-state + baz (return 1000)] + (return (+ (+ foo bar) baz)))) + +(def (run-state monad state) + (monad state)) + (def (interpose elem list) (case list (#Cons x (#Cons y list')) |