aboutsummaryrefslogtreecommitdiff
path: root/test2.lux
diff options
context:
space:
mode:
authorEduardo Julian2015-01-16 11:26:17 -0400
committerEduardo Julian2015-01-16 11:26:17 -0400
commit90e35a2d13c78c8d7a3db3020bf6a66a5fe04604 (patch)
tree1803231a22c7e62aa5181cfee6450765f584f907 /test2.lux
parentd1e7c4dd03a72a93dbca15cbc1b0ac29ab49efbc (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.lux28
1 files changed, 24 insertions, 4 deletions
diff --git a/test2.lux b/test2.lux
index d24c9d10b..e5e3ad6da 100644
--- a/test2.lux
+++ b/test2.lux
@@ -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)