diff options
author | Eduardo Julian | 2015-01-16 11:26:17 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-01-16 11:26:17 -0400 |
commit | 90e35a2d13c78c8d7a3db3020bf6a66a5fe04604 (patch) | |
tree | 1803231a22c7e62aa5181cfee6450765f584f907 /test2.lux | |
parent | d1e7c4dd03a72a93dbca15cbc1b0ac29ab49efbc (diff) |
[Bugs]
- Not all outside vars needed by lambdas were actually captured.
- Needed vars weren't always captured in the right order.
- The names of global-var classes weren't being generated properly to account for symbols/punctuation.
[Enhancements]
- The system now uses a brand-new ClassLoader on every run to speed-up development.
Diffstat (limited to 'test2.lux')
-rw-r--r-- | test2.lux | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -150,7 +150,7 @@ (#Failure message)) (def (return* state value) - (#Ok state value)) + (#Ok [state value])) (def (fail message) (lambda [state] @@ -158,13 +158,13 @@ (def (return value) (lambda [state] - (#Ok state value))) + (#Ok [state value]))) (def (bind m-value step) (lambda [state] (let inputs (m-value state) (case inputs - (#Ok ?state ?datum) + (#Ok [?state ?datum]) (step ?datum ?state) _ @@ -294,6 +294,19 @@ (do (print "[") (print idx) (print ":") (print x) (print "]") (print " ") (print-enum enum')))) +(def get-state + (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)) + ## Program (def (main args) (case (' ((~ "Oh yeah..."))) @@ -313,7 +326,14 @@ (println (= false true)) (println (= true false)) (println (= true true)) - (print-enum (enumerate (list #"a" #"b" #"c" #"d" #"e")))) + (case (run-state monadic-dup 123) + (#Ok [_ ?value]) + (println ?value) + + (#Failure ?message) + (println ?message)) + (print-enum (enumerate (list #"a" #"b" #"c" #"d" #"e"))) + ) )) #( (def (main args) |