diff options
Diffstat (limited to 'source/lux')
-rw-r--r-- | source/lux/codata/lazy.lux | 4 | ||||
-rw-r--r-- | source/lux/codata/stream.lux | 12 | ||||
-rw-r--r-- | source/lux/data/io.lux | 20 | ||||
-rw-r--r-- | source/lux/data/list.lux | 16 | ||||
-rw-r--r-- | source/lux/data/text.lux | 14 | ||||
-rw-r--r-- | source/lux/host/jvm.lux | 116 | ||||
-rw-r--r-- | source/lux/meta/lux.lux | 20 | ||||
-rw-r--r-- | source/lux/meta/syntax.lux | 28 |
8 files changed, 115 insertions, 115 deletions
diff --git a/source/lux/codata/lazy.lux b/source/lux/codata/lazy.lux index fb0c0bcb3..542bb9922 100644 --- a/source/lux/codata/lazy.lux +++ b/source/lux/codata/lazy.lux @@ -19,9 +19,9 @@ ## [Syntax] (defmacro #export (... tokens state) (case tokens - (\ (list value)) + (\ (@list value)) (let [blank (symbol$ ["" ""])] - (#;Right [state (list (` (;lambda [(~ blank)] ((~ blank) (~ value)))))])) + (#;Right [state (@list (` (;lambda [(~ blank)] ((~ blank) (~ value)))))])) _ (#;Left "Wrong syntax for ..."))) diff --git a/source/lux/codata/stream.lux b/source/lux/codata/stream.lux index d0f84f0c7..a25a19b5f 100644 --- a/source/lux/codata/stream.lux +++ b/source/lux/codata/stream.lux @@ -10,7 +10,7 @@ (meta lux macro syntax) - (data (list #as l #refer (#only list list& List/Monad)) + (data (list #as l #refer (#only @list @list& List/Monad)) (number (int #open ("i" Int/Number Int/Ord))) bool) (codata (lazy #as L #refer #all)))) @@ -67,8 +67,8 @@ (-> <det-type> (Stream a) (List a))) (let [[x xs'] (! xs)] (if <det-test> - (list& x (<taker> <det-step> xs')) - (list)))) + (@list& x (<taker> <det-step> xs')) + (@list)))) (def #export (<dropper> det xs) (All [a] @@ -85,7 +85,7 @@ (if <det-test> (let [[tail next] (<splitter> <det-step> xs')] [(#;Cons [x tail]) next]) - [(list) xs])))] + [(@list) xs])))] [take-while drop-while split-with (-> a Bool) (det x) det] [take drop split Int (i> det 0) (i+ -1 det)] @@ -128,5 +128,5 @@ #let [patterns+ (: (List AST) (do List/Monad [pattern (l;reverse patterns)] - (: (List AST) (list (` [(~ pattern) (~ g!s)]) (` (L;! (~ g!s)))))))]] - (wrap (list g!s (` (;let [(~@ patterns+)] (~ body))))))) + (: (List AST) (@list (` [(~ pattern) (~ g!s)]) (` (L;! (~ g!s)))))))]] + (wrap (@list g!s (` (;let [(~@ patterns+)] (~ body))))))) diff --git a/source/lux/data/io.lux b/source/lux/data/io.lux index 1ca68f518..5c54c0369 100644 --- a/source/lux/data/io.lux +++ b/source/lux/data/io.lux @@ -16,25 +16,25 @@ (-> (,) a)) ## [Syntax] -(defmacro #export (io tokens state) +(defmacro #export (@io tokens state) (case tokens - (\ (list value)) + (\ (@list value)) (let [blank (symbol$ ["" ""])] - (#;Right [state (list (` (;_lux_lambda (~ blank) (~ blank) (~ value))))])) + (#;Right [state (@list (` (;_lux_lambda (~ blank) (~ blank) (~ value))))])) _ - (#;Left "Wrong syntax for io"))) + (#;Left "Wrong syntax for @io"))) ## [Structures] (defstruct #export IO/Functor (F;Functor IO) (def (map f ma) - (io (f (ma []))))) + (@io (f (ma []))))) (defstruct #export IO/Monad (M;Monad IO) (def _functor IO/Functor) (def (wrap x) - (io x)) + (@io x)) (def (join mma) (mma []))) @@ -42,10 +42,10 @@ ## [Functions] (def #export (print x) (-> Text (IO (,))) - (io (_jvm_invokevirtual "java.io.PrintStream" "print" ["java.lang.String"] - (_jvm_getstatic "java.lang.System" "out") [x]))) + (@io (_jvm_invokevirtual "java.io.PrintStream" "print" ["java.lang.String"] + (_jvm_getstatic "java.lang.System" "out") [x]))) (def #export (println x) (-> Text (IO (,))) - (io (_jvm_invokevirtual "java.io.PrintStream" "println" ["java.lang.String"] - (_jvm_getstatic "java.lang.System" "out") [x]))) + (@io (_jvm_invokevirtual "java.io.PrintStream" "println" ["java.lang.String"] + (_jvm_getstatic "java.lang.System" "out") [x]))) diff --git a/source/lux/data/list.lux b/source/lux/data/list.lux index 7df2eb358..489ac5b4f 100644 --- a/source/lux/data/list.lux +++ b/source/lux/data/list.lux @@ -213,23 +213,23 @@ (@ (i+ -1 i) xs')))) ## [Syntax] -(defmacro #export (list xs state) +(defmacro #export (@list xs state) (#;Right state (#;Cons (foldL (: (-> AST AST AST) (lambda [tail head] (` (#;Cons (~ head) (~ tail))))) (: AST (` #;Nil)) (reverse xs)) #;Nil))) -(defmacro #export (list& xs state) +(defmacro #export (@list& xs state) (case (reverse xs) (#;Cons last init) - (#;Right state (list (foldL (: (-> AST AST AST) + (#;Right state (@list (foldL (: (-> AST AST AST) (lambda [tail head] (` (#;Cons (~ head) (~ tail))))) last init))) _ - (#;Left "Wrong syntax for list&"))) + (#;Left "Wrong syntax for @list&"))) ## [Structures] ## (defstruct #export (List/Eq eq) (All [a] (-> (Eq a) (Eq (List a)))) @@ -257,14 +257,14 @@ (defstruct #export List/Functor (Functor List) (def (map f ma) (case ma - #;Nil #;Nil - (#;Cons [a ma']) (#;Cons [(f a) (map f ma')])))) + #;Nil #;Nil + (#;Cons a ma') (#;Cons (f a) (map f ma'))))) (defstruct #export List/Monad (Monad List) (def _functor List/Functor) (def (wrap a) - (#;Cons [a #;Nil])) + (#;Cons a #;Nil)) (def (join mma) (using List/Monoid @@ -282,4 +282,4 @@ (let [pre (filter (>= x) xs') post (filter (< x) xs') ++ (:: List/Monoid m;++)] - ($ ++ (sort ord pre) (list x) (sort ord post)))))) + ($ ++ (sort ord pre) (@list x) (sort ord post)))))) diff --git a/source/lux/data/text.lux b/source/lux/data/text.lux index 533308dd0..e54dff5c0 100644 --- a/source/lux/data/text.lux +++ b/source/lux/data/text.lux @@ -13,7 +13,7 @@ (monad #as M #refer #all)) (data (number (int #open ("i" Int/Number Int/Ord))) maybe - (list #refer (#only foldL list list&))))) + (list #refer (#only foldL @list @list&))))) ## [Functions] (def #export (size x) @@ -158,18 +158,18 @@ (-> Text (List AST)) (case (extract-var template) (#;Some [pre var post]) - (list& (text$ pre) (symbol$ ["" var]) - (unravel-template post)) + (@list& (text$ pre) (symbol$ ["" var]) + (unravel-template post)) #;None - (list (text$ template)))) + (@list (text$ template)))) (defmacro #export (<> tokens state) (case tokens - (\ (list [_ (#;TextS template)])) + (\ (@list [_ (#;TextS template)])) (let [++ (symbol$ ["" ""])] - (#;Right state (list (` (;let [(~ ++) (;:: Text/Monoid m;++)] - (;$ (~ ++) (~@ (unravel-template template)))))))) + (#;Right state (@list (` (;let [(~ ++) (;:: Text/Monoid m;++)] + (;$ (~ ++) (~@ (unravel-template template)))))))) _ (#;Left "Wrong syntax for <>"))) diff --git a/source/lux/host/jvm.lux b/source/lux/host/jvm.lux index d7992509a..7a564826c 100644 --- a/source/lux/host/jvm.lux +++ b/source/lux/host/jvm.lux @@ -82,21 +82,21 @@ ## [Syntax] (defsyntax #export (throw ex) - (emit (list (` (;_jvm_throw (~ ex)))))) + (emit (@list (` (;_jvm_throw (~ ex)))))) (defsyntax #export (try body [catches (*^ catch^)] [finally (?^ finally^)]) - (emit (list (` (;_jvm_try (~ body) - (~@ (:: List/Monoid (m;++ (map (: (-> (, Text Ident AST) AST) - (lambda [catch] - (let [[class ex body] catch] - (` (;_jvm_catch (~ (text$ class)) (~ (symbol$ ex)) (~ body)))))) - catches) - (case finally - #;None - (list) - - (#;Some finally) - (: (List AST) (list (` (;_jvm_finally (~ finally)))))))))))))) + (emit (@list (` (;_jvm_try (~ body) + (~@ (:: List/Monoid (m;++ (map (: (-> (, Text Ident AST) AST) + (lambda [catch] + (let [[class ex body] catch] + (` (;_jvm_catch (~ (text$ class)) (~ (symbol$ ex)) (~ body)))))) + catches) + (case finally + #;None + (@list) + + (#;Some finally) + (: (List AST) (@list (` (;_jvm_finally (~ finally)))))))))))))) (defsyntax #export (definterface [name local-symbol^] [supers (tuple^ (*^ local-symbol^))] [members (*^ method-decl^)]) (let [members' (map (: (-> (, (List Text) Text (List Text) Text) AST) @@ -104,8 +104,8 @@ (let [[modifiers name inputs output] member] (` ((~ (text$ name)) [(~@ (map text$ inputs))] (~ (text$ output)) [(~@ (map text$ modifiers))]))))) members)] - (emit (list (` (;_jvm_interface (~ (text$ name)) [(~@ (map text$ supers))] - (~@ members'))))))) + (emit (@list (` (;_jvm_interface (~ (text$ name)) [(~@ (map text$ supers))] + (~@ members'))))))) (defsyntax #export (defclass [name local-symbol^] [super local-symbol^] [interfaces (tuple^ (*^ local-symbol^))] [fields (*^ field-decl^)] @@ -126,44 +126,44 @@ [(~@ (map (: (-> (, Text Text) AST) (lambda [in] (let [[left right] in] - (form$ (list (symbol$ ["" left]) - (text$ right)))))) + (form$ (@list (symbol$ ["" left]) + (text$ right)))))) inputs))] (~ (text$ output)) [(~@ (map text$ modifiers))] (~ body)))))) methods)]] - (emit (list (` (;_jvm_class (~ (text$ name)) (~ (text$ super)) - [(~@ (map text$ interfaces))] - [(~@ fields')] - [(~@ methods')])))))) + (emit (@list (` (;_jvm_class (~ (text$ name)) (~ (text$ super)) + [(~@ (map text$ interfaces))] + [(~@ fields')] + [(~@ methods')])))))) (defsyntax #export (new [class local-symbol^] [arg-classes (tuple^ (*^ local-symbol^))] [args (tuple^ (*^ id^))]) - (emit (list (` (;_jvm_new (~ (text$ class)) - [(~@ (map text$ arg-classes))] - [(~@ args)]))))) + (emit (@list (` (;_jvm_new (~ (text$ class)) + [(~@ (map text$ arg-classes))] + [(~@ args)]))))) (defsyntax #export (instance? [class local-symbol^] obj) - (emit (list (` (;_jvm_instanceof (~ (text$ class)) (~ obj)))))) + (emit (@list (` (;_jvm_instanceof (~ (text$ class)) (~ obj)))))) (defsyntax #export (locking lock body) (do Lux/Monad [g!lock (gensym "") g!body (gensym "") g!_ (gensym "")] - (emit (list (` (let [(~ g!lock) (~ lock) - (~ g!_) (;_jvm_monitorenter (~ g!lock)) - (~ g!body) (~ body) - (~ g!_) (;_jvm_monitorexit (~ g!lock))] - (~ g!body))))) + (emit (@list (` (let [(~ g!lock) (~ lock) + (~ g!_) (;_jvm_monitorenter (~ g!lock)) + (~ g!body) (~ body) + (~ g!_) (;_jvm_monitorexit (~ g!lock))] + (~ g!body))))) )) (defsyntax #export (null? obj) - (emit (list (` (;_jvm_null? (~ obj)))))) + (emit (@list (` (;_jvm_null? (~ obj)))))) (defsyntax #export (program [args symbol^] body) - (emit (list (` (;_jvm_program (~ (symbol$ args)) - (~ body)))))) + (emit (@list (` (;_jvm_program (~ (symbol$ args)) + (~ body)))))) (defsyntax #export (.? [field local-symbol^] obj) (case obj @@ -172,7 +172,7 @@ [obj-type (find-var-type obj-name)] (case obj-type (#;DataT class) - (emit (list (` (;_jvm_getfield (~ (text$ class)) (~ (text$ field)))))) + (emit (@list (` (;_jvm_getfield (~ (text$ class)) (~ (text$ field)))))) _ (fail "Can only get field from object."))) @@ -180,8 +180,8 @@ _ (do Lux/Monad [g!obj (gensym "")] - (emit (list (` (let [(~ g!obj) (~ obj)] - (;;.? (~ (text$ field)) (~ g!obj))))))))) + (emit (@list (` (let [(~ g!obj) (~ obj)] + (;;.? (~ (text$ field)) (~ g!obj))))))))) (defsyntax #export (.= [field local-symbol^] value obj) (case obj @@ -190,7 +190,7 @@ [obj-type (find-var-type obj-name)] (case obj-type (#;DataT class) - (emit (list (` (;_jvm_putfield (~ (text$ class)) (~ (text$ field)) (~ value))))) + (emit (@list (` (;_jvm_putfield (~ (text$ class)) (~ (text$ field)) (~ value))))) _ (fail "Can only set field of object."))) @@ -198,8 +198,8 @@ _ (do Lux/Monad [g!obj (gensym "")] - (emit (list (` (let [(~ g!obj) (~ obj)] - (;;.= (~ (text$ field)) (~ value) (~ g!obj))))))))) + (emit (@list (` (let [(~ g!obj) (~ obj)] + (;;.= (~ (text$ field)) (~ value) (~ g!obj))))))))) (defsyntax #export (.! [call method-call^] obj) (let [[m-name ?m-classes m-args] call] @@ -209,8 +209,8 @@ [obj-type (find-var-type obj-name)] (case obj-type (#;DataT class) - (emit (list (` (;_jvm_invokevirtual (~ (text$ class)) (~ (text$ m-name)) [(~@ (map text$ ?m-classes))] - (~ obj) [(~@ m-args)])))) + (emit (@list (` (;_jvm_invokevirtual (~ (text$ class)) (~ (text$ m-name)) [(~@ (map text$ ?m-classes))] + (~ obj) [(~@ m-args)])))) _ (fail "Can only call method on object."))) @@ -218,33 +218,33 @@ _ (do Lux/Monad [g!obj (gensym "")] - (emit (list (` (let [(~ g!obj) (~ obj)] - (;;.! ((~ (symbol$ ["" m-name])) - [(~@ (map (lambda [c] (symbol$ ["" c])) ?m-classes))] - [(~@ m-args)]) - (~ g!obj)))))))))) + (emit (@list (` (let [(~ g!obj) (~ obj)] + (;;.! ((~ (symbol$ ["" m-name])) + [(~@ (map (lambda [c] (symbol$ ["" c])) ?m-classes))] + [(~@ m-args)]) + (~ g!obj)))))))))) (defsyntax #export (..? [field local-symbol^] [class local-symbol^]) - (emit (list (` (;_jvm_getstatic (~ (text$ class)) (~ (text$ field))))))) + (emit (@list (` (;_jvm_getstatic (~ (text$ class)) (~ (text$ field))))))) (defsyntax #export (..= [field local-symbol^] value [class local-symbol^]) - (emit (list (` (;_jvm_putstatic (~ (text$ class)) (~ (text$ field)) (~ value)))))) + (emit (@list (` (;_jvm_putstatic (~ (text$ class)) (~ (text$ field)) (~ value)))))) (defsyntax #export (..! [call method-call^] [class local-symbol^]) (let [[m-name m-classes m-args] call] - (emit (list (` (;_jvm_invokestatic (~ (text$ class)) (~ (text$ m-name)) - [(~@ (map text$ m-classes))] - [(~@ m-args)])))))) + (emit (@list (` (;_jvm_invokestatic (~ (text$ class)) (~ (text$ m-name)) + [(~@ (map text$ m-classes))] + [(~@ m-args)])))))) (defsyntax #export (->maybe expr) (do Lux/Monad [g!val (gensym "")] - (emit (list (` (let [(~ g!val) (~ expr)] - (if (null? (~ g!val)) - #;None - (#;Some (~ g!val))))))))) + (emit (@list (` (let [(~ g!val) (~ expr)] + (if (null? (~ g!val)) + #;None + (#;Some (~ g!val))))))))) (defsyntax #export (try$ expr) - (emit (list (` (try (#;Right (~ expr)) - (~ (' (catch java.lang.Exception e - (#;Left (.! (getMessage [] []) e)))))))))) + (emit (@list (` (try (#;Right (~ expr)) + (~ (' (catch java.lang.Exception e + (#;Left (.! (getMessage [] []) e)))))))))) diff --git a/source/lux/meta/lux.lux b/source/lux/meta/lux.lux index 32ca78570..df3ebae48 100644 --- a/source/lux/meta/lux.lux +++ b/source/lux/meta/lux.lux @@ -131,10 +131,10 @@ (wrap (:: List/Monad (M;join expansion')))) #;None - (:: Lux/Monad (M;wrap (list syntax))))) + (:: Lux/Monad (M;wrap (@list syntax))))) _ - (:: Lux/Monad (M;wrap (list syntax))))) + (:: Lux/Monad (M;wrap (@list syntax))))) (def #export (macro-expand-all syntax) (-> AST (Lux (List AST))) @@ -152,22 +152,22 @@ #;None (do Lux/Monad - [parts' (M;map% Lux/Monad macro-expand-all (list& (symbol$ macro-name) args))] - (wrap (list (form$ (:: List/Monad (M;join parts')))))))) + [parts' (M;map% Lux/Monad macro-expand-all (@list& (symbol$ macro-name) args))] + (wrap (@list (form$ (:: List/Monad (M;join parts')))))))) [_ (#;FormS (#;Cons [harg targs]))] (do Lux/Monad [harg+ (macro-expand-all harg) targs+ (M;map% Lux/Monad macro-expand-all targs)] - (wrap (list (form$ (list:++ harg+ (:: List/Monad (M;join (: (List (List AST)) targs+)))))))) + (wrap (@list (form$ (list:++ harg+ (:: List/Monad (M;join (: (List (List AST)) targs+)))))))) [_ (#;TupleS members)] (do Lux/Monad [members' (M;map% Lux/Monad macro-expand-all members)] - (wrap (list (tuple$ (:: List/Monad (M;join members')))))) + (wrap (@list (tuple$ (:: List/Monad (M;join members')))))) _ - (:: Lux/Monad (M;wrap (list syntax))))) + (:: Lux/Monad (M;wrap (@list syntax))))) (def #export (gensym prefix state) (-> Text (Lux AST)) @@ -191,7 +191,7 @@ (do Lux/Monad [token+ (macro-expand token)] (case token+ - (\ (list token')) + (\ (@list token')) (wrap token') _ @@ -216,8 +216,8 @@ (lambda [gdef] (let [[name [export? _]] gdef] (if export? - (list name) - (list))))) + (@list name) + (@list))))) (get@ #;defs =module)))])) #;None diff --git a/source/lux/meta/syntax.lux b/source/lux/meta/syntax.lux index df79772c1..3bc3196e2 100644 --- a/source/lux/meta/syntax.lux +++ b/source/lux/meta/syntax.lux @@ -27,7 +27,7 @@ (All [a] (-> (List (, a a)) (List a))) (case pairs #;Nil #;Nil - (#;Cons [[x y] pairs']) (list& x y (join-pairs pairs')))) + (#;Cons [[x y] pairs']) (@list& x y (join-pairs pairs')))) ## [Types] (deftype #export (Parser a) @@ -160,10 +160,10 @@ (All [a] (-> (Parser a) (Parser (List a)))) (case (p tokens) - #;None (#;Some [tokens (list)]) + #;None (#;Some [tokens (@list)]) (#;Some [tokens' x]) (run-parser (do Parser/Monad [xs (*^ p)] - (wrap (list& x xs))) + (wrap (@list& x xs))) tokens'))) (def #export (+^ p) @@ -172,7 +172,7 @@ (do Parser/Monad [x p xs (*^ p)] - (wrap (list& x xs)))) + (wrap (@list& x xs)))) (def #export (&^ p1 p2) (All [a b] @@ -212,21 +212,21 @@ (defmacro #export (defsyntax tokens) (let [[exported? tokens] (: (, Bool (List AST)) (case tokens - (\ (list& [_ (#;TagS ["" "export"])] tokens')) + (\ (@list& [_ (#;TagS ["" "export"])] tokens')) [true tokens'] _ [false tokens]))] (case tokens - (\ (list [_ (#;FormS (list& [_ (#;SymbolS ["" name])] args))] - body)) + (\ (@list [_ (#;FormS (@list& [_ (#;SymbolS ["" name])] args))] + body)) (do Lux/Monad [names+parsers (M;map% Lux/Monad (: (-> AST (Lux (, AST AST))) (lambda [arg] (case arg - (\ [_ (#;TupleS (list [_ (#;SymbolS var-name)] - parser))]) + (\ [_ (#;TupleS (@list [_ (#;SymbolS var-name)] + parser))]) (wrap [(symbol$ var-name) parser]) (\ [_ (#;SymbolS var-name)]) @@ -249,14 +249,14 @@ (~ g!_) (l;fail (~ error-msg))))))) body - (: (List (, AST AST)) (list& [(symbol$ ["" ""]) (` end^)] (reverse names+parsers)))) + (: (List (, AST AST)) (@list& [(symbol$ ["" ""]) (` end^)] (reverse names+parsers)))) macro-def (: AST (` (defmacro ((~ (symbol$ ["" name])) (~ g!tokens)) (~ body'))))]] - (wrap (list& macro-def - (if exported? - (list (` (;_lux_export (~ (symbol$ ["" name]))))) - (list))))) + (wrap (@list& macro-def + (if exported? + (@list (` (;_lux_export (~ (symbol$ ["" name]))))) + (@list))))) _ (l;fail "Wrong syntax for defsyntax")))) |