aboutsummaryrefslogtreecommitdiff
path: root/test2.lang
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test2.lang47
1 files changed, 46 insertions, 1 deletions
diff --git a/test2.lang b/test2.lang
index 243ab902a..13fabc59a 100644
--- a/test2.lang
+++ b/test2.lang
@@ -1,5 +1,5 @@
(import java.lang.System)
-## (require "./another" as another)
+(require "./another" as another)
(definterface Function
(: apply (-> [java.lang.Object] java.lang.Object)))
@@ -46,6 +46,51 @@
(#Quote form*)
)))
+## Utils
+(def (fail* message)
+ (#Failure message))
+
+(def (return* state value)
+ (#Ok state value))
+
+(def (fail message)
+ (lambda [state]
+ (#Failure message)))
+
+(def (return value)
+ (lambda [state]
+ (#Ok state value)))
+
+(def (bind m-value step)
+ (lambda [state]
+ (let inputs (m-value state)
+ (case inputs
+ (#Ok ?state ?datum)
+ (step ?datum ?state)
+
+ _
+ inputs))))
+
+## Ideally, this is what I want...
+## (exec [yolo lol
+## #let [foo bar]
+## #when foo]
+## (meme yolo foo))
+
+(defmacro (exec tokens)
+ (case tokens
+ (#Cons (#Tuple steps) (#Cons return #Nil))
+ (if (= 0 (mod (length steps) 2))
+ (fold (lambda [inner pair]
+ (case pair
+ [label computation]
+ (` (bind (~ computation)
+ (lambda [(~ label)] (~ inner))))))
+ return
+ (as-pairs steps))
+ (#Text "Oh no!"))))
+
+## Program
(def (main args)
(case (' ((~ "TROLOLOL")))
(#Form (#Cons (#Text text) #Nil))