aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/lux.lux108
-rw-r--r--source/test2.lux8
2 files changed, 59 insertions, 57 deletions
diff --git a/source/lux.lux b/source/lux.lux
index 8f02c681d..2b008f95f 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -1,79 +1,96 @@
## Base interfaces & classes
-(jvm/definterface Function
+(jvm:interface Function
(: apply (-> [java.lang.Object] java.lang.Object)))
-(jvm/defclass Tuple0 java.lang.Object
+(jvm:class Tuple0 java.lang.Object
[])
-(jvm/defclass Tuple1 java.lang.Object
+(jvm:class Tuple1 java.lang.Object
[[java.lang.Object _1]])
-(jvm/defclass Tuple2 java.lang.Object
+(jvm:class Tuple2 java.lang.Object
[[java.lang.Object _1] [java.lang.Object _2]])
-(jvm/defclass Tuple3 java.lang.Object
+(jvm:class Tuple3 java.lang.Object
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3]])
-(jvm/defclass Tuple4 java.lang.Object
+(jvm:class Tuple4 java.lang.Object
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]])
-(jvm/defclass Tuple5 java.lang.Object
+(jvm:class Tuple5 java.lang.Object
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]
[java.lang.Object _5]])
-(jvm/defclass Tuple6 java.lang.Object
+(jvm:class Tuple6 java.lang.Object
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]
[java.lang.Object _5] [java.lang.Object _6]])
-(jvm/defclass Tuple7 java.lang.Object
+(jvm:class Tuple7 java.lang.Object
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]
[java.lang.Object _5] [java.lang.Object _6]
[java.lang.Object _7]])
-(jvm/defclass Tuple8 java.lang.Object
+(jvm:class Tuple8 java.lang.Object
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]
[java.lang.Object _5] [java.lang.Object _6]
[java.lang.Object _7] [java.lang.Object _8]])
-(jvm/defclass Variant java.lang.Object
+(jvm:class Variant java.lang.Object
[[java.lang.String tag]])
-(jvm/defclass Variant0 lux.Variant
+(jvm:class Variant0 lux.Variant
[])
-(jvm/defclass Variant1 lux.Variant
+(jvm:class Variant1 lux.Variant
[[java.lang.Object _1]])
-(jvm/defclass Variant2 lux.Variant
+(jvm:class Variant2 lux.Variant
[[java.lang.Object _1] [java.lang.Object _2]])
-(jvm/defclass Variant3 lux.Variant
+(jvm:class Variant3 lux.Variant
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3]])
-(jvm/defclass Variant4 lux.Variant
+(jvm:class Variant4 lux.Variant
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]])
-(jvm/defclass Variant5 lux.Variant
+(jvm:class Variant5 lux.Variant
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]
[java.lang.Object _5]])
-(jvm/defclass Variant6 lux.Variant
+(jvm:class Variant6 lux.Variant
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]
[java.lang.Object _5] [java.lang.Object _6]])
-(jvm/defclass Variant7 lux.Variant
+(jvm:class Variant7 lux.Variant
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]
[java.lang.Object _5] [java.lang.Object _6]
[java.lang.Object _7]])
-(jvm/defclass Variant8 lux.Variant
+(jvm:class Variant8 lux.Variant
[[java.lang.Object _1] [java.lang.Object _2]
[java.lang.Object _3] [java.lang.Object _4]
[java.lang.Object _5] [java.lang.Object _6]
[java.lang.Object _7] [java.lang.Object _8]])
## Base functions & macros
-(defmacro (list xs)
- (case xs
+(def (id x)
+ x)
+
+(def (fold f init values)
+ (case values
#Nil
- (#Tag "Nil")
+ init
+ (#Cons x xs)
+ (fold f (f init x) xs)))
- (#Cons x xs*)
- (#Form (#Cons (#Tag "Cons") (#Cons x (#Cons (list xs*) #Nil))))))
+(def (cons tail head)
+ (#Cons head tail))
+
+(def (reverse list)
+ (fold cons #Nil list))
+
+(annotate list Macro)
+(def (list xs)
+ (fold (lambda [tail head]
+ (#Form (#Cons (#Tag "Cons")
+ (#Cons head
+ (#Cons tail #Nil)))))
+ (#Tag "Nil")
+ (reverse xs)))
(def (++ xs ys)
(case xs
@@ -135,40 +152,31 @@
## I/O
(def (print x)
- (jvm/invokevirtual java.io.PrintStream "print" [Object]
- (jvm/getstatic System out) [x]))
+ (jvm:invokevirtual java.io.PrintStream "print" [Object]
+ (jvm:getstatic System out) [x]))
(def (println x)
- (jvm/invokevirtual java.io.PrintStream "println" [Object]
- (jvm/getstatic System out) [x]))
+ (jvm:invokevirtual java.io.PrintStream "println" [Object]
+ (jvm:getstatic System out) [x]))
-(defmacro (' form)
+(annotate ' Macro)
+(def (' form)
(case form
(#Cons token #Nil)
(untemplate token)))
(def (+ x y)
- (jvm/i+ x y))
+ (jvm:iadd x y))
(def inc (+ 1))
-(def (id x)
- x)
-
-(def (fold f init values)
- (case values
- #Nil
- init
- (#Cons x xs)
- (fold f (f init x) xs)))
-
(def length (fold (lambda [l x] (inc l)) 0))
(def (rem dividend divisor)
- (jvm/irem dividend divisor))
+ (jvm:irem dividend divisor))
(def (= x y)
- (jvm/invokevirtual Object "equals" [Object]
+ (jvm:invokevirtual Object "equals" [Object]
x [y]))
(def (pairs list)
@@ -180,11 +188,11 @@
#Nil))
(def (show x)
- (jvm/invokevirtual Object "toString" []
+ (jvm:invokevirtual Object "toString" []
x []))
(def (concat t1 t2)
- (jvm/invokevirtual String "concat" [String]
+ (jvm:invokevirtual String "concat" [String]
t1 [t2]))
(def (range from to)
@@ -193,19 +201,13 @@
(#Cons from (range (inc from) to))))
(def (text->list text)
- (let length (jvm/invokevirtual String "length" []
+ (let length (jvm:invokevirtual String "length" []
text [])
(map (lambda [idx]
- (jvm/invokevirtual String "charAt" [int]
+ (jvm:invokevirtual String "charAt" [int]
text [idx]))
(range 0 length))))
-(def (cons tail head)
- (#Cons head tail))
-
-(def (reverse list)
- (fold cons #Nil list))
-
(def (enumerate list)
(case (fold (lambda [state x]
(case state
diff --git a/source/test2.lux b/source/test2.lux
index c72602edb..f2fe02bb8 100644
--- a/source/test2.lux
+++ b/source/test2.lux
@@ -1,4 +1,4 @@
-(use "./util" as util)
+(require "./util")
(def (print-enum enum)
(case enum
@@ -10,10 +10,10 @@
(print-enum enum'))))
#((def monadic-dup
- (util/exec [foo get-state
+ (util:exec [foo get-state
bar get-state
- baz (util/return 1000)]
- (util/return (+ (+ foo bar) baz)))))#
+ baz (util:return 1000)]
+ (util:return (+ (+ foo bar) baz)))))#
(def (print-map list-map)
(do (print "{")