diff options
Diffstat (limited to 'source/lux')
-rw-r--r-- | source/lux/codata/stream.lux | 2 | ||||
-rw-r--r-- | source/lux/control/comonad.lux | 4 | ||||
-rw-r--r-- | source/lux/control/dict.lux | 18 | ||||
-rw-r--r-- | source/lux/control/monad.lux | 6 | ||||
-rw-r--r-- | source/lux/control/stack.lux | 20 | ||||
-rw-r--r-- | source/lux/data/list.lux | 76 | ||||
-rw-r--r-- | source/lux/data/text.lux | 2 | ||||
-rw-r--r-- | source/lux/host/jvm.lux | 8 | ||||
-rw-r--r-- | source/lux/meta/ast.lux | 2 | ||||
-rw-r--r-- | source/lux/meta/lux.lux | 8 | ||||
-rw-r--r-- | source/lux/meta/macro.lux | 16 | ||||
-rw-r--r-- | source/lux/meta/syntax.lux | 18 |
12 files changed, 41 insertions, 139 deletions
diff --git a/source/lux/codata/stream.lux b/source/lux/codata/stream.lux index b4c0e0239..5415213d7 100644 --- a/source/lux/codata/stream.lux +++ b/source/lux/codata/stream.lux @@ -128,5 +128,5 @@ #let [patterns+ (: (List AST) (do List/Monad [pattern (l;reverse patterns)] - (list (` [(~ pattern) (~ g!s)]) (` (L;! (~ g!s))))))]] + (: (List AST) (list (` [(~ pattern) (~ g!s)]) (` (L;! (~ g!s)))))))]] (wrap (list g!s (` (;let [(~@ patterns+)] (~ body))))))) diff --git a/source/lux/control/comonad.lux b/source/lux/control/comonad.lux index 6225af338..052b8768d 100644 --- a/source/lux/control/comonad.lux +++ b/source/lux/control/comonad.lux @@ -29,12 +29,12 @@ ## [Syntax] (defmacro #export (be tokens state) (case tokens - (\ (list monad (#;Meta [_ (#;TupleS bindings)]) body)) + (\ (list monad [_ (#;TupleS bindings)] body)) (let [body' (foldL (: (-> AST (, AST AST) AST) (lambda [body' binding] (let [[var value] binding] (case var - (#;Meta [_ (#;TagS ["" "let"])]) + [_ (#;TagS ["" "let"])] (` (;let (~ value) (~ body'))) _ diff --git a/source/lux/control/dict.lux b/source/lux/control/dict.lux deleted file mode 100644 index 0b2069cf3..000000000 --- a/source/lux/control/dict.lux +++ /dev/null @@ -1,18 +0,0 @@ -## Copyright (c) Eduardo Julian. All rights reserved. -## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -## If a copy of the MPL was not distributed with this file, -## You can obtain one at http://mozilla.org/MPL/2.0/. - -(;import lux) - -## Signatures -(defsig #export (Dict d) - (: (All [k v] - (-> k (d k v) (Maybe v))) - get) - (: (All [k v] - (-> k v (d k v) (d k v))) - put) - (: (All [k v] - (-> k (d k v) (d k v))) - remove)) diff --git a/source/lux/control/monad.lux b/source/lux/control/monad.lux index 707bf7497..df48da863 100644 --- a/source/lux/control/monad.lux +++ b/source/lux/control/monad.lux @@ -50,15 +50,15 @@ ## [Syntax] (defmacro #export (do tokens state) (case tokens - ## (\ (list monad (#;Meta [_ (#;TupleS bindings)]) body)) - (#;Cons [monad (#;Cons [(#;Meta [_ (#;TupleS bindings)]) (#;Cons [body #;Nil])])]) + ## (\ (list monad [_ (#;TupleS bindings)] body)) + (#;Cons [monad (#;Cons [[_ (#;TupleS bindings)] (#;Cons [body #;Nil])])]) (let [g!map (symbol$ ["" " map "]) g!join (symbol$ ["" " join "]) body' (foldL (: (-> AST (, AST AST) AST) (lambda [body' binding] (let [[var value] binding] (case var - (#;Meta [_ (#;TagS ["" "let"])]) + [_ (#;TagS ["" "let"])] (` (;let (~ value) (~ body'))) _ diff --git a/source/lux/control/stack.lux b/source/lux/control/stack.lux deleted file mode 100644 index 206ab5cd7..000000000 --- a/source/lux/control/stack.lux +++ /dev/null @@ -1,20 +0,0 @@ -## Copyright (c) Eduardo Julian. All rights reserved. -## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -## If a copy of the MPL was not distributed with this file, -## You can obtain one at http://mozilla.org/MPL/2.0/. - -(;import lux) - -## [Signatures] -(defsig #export (Stack s) - (: (All [a] (s a)) - empty) - (: (All [a] (-> (s a) Bool)) - empty?) - (: (All [a] (-> a (s a) (s a))) - push) - (: (All [a] (-> (s a) (Maybe (s a)))) - pop) - (: (All [a] (-> (s a) (Maybe a))) - top) - ) diff --git a/source/lux/data/list.lux b/source/lux/data/list.lux index 1277fc6ae..10bbb8086 100644 --- a/source/lux/data/list.lux +++ b/source/lux/data/list.lux @@ -8,9 +8,7 @@ (functor #as F #refer #all) (monad #as M #refer #all) (eq #as E) - (ord #as O) - (dict #as D #refer #all) - (stack #as S)) + (ord #as O)) (data (number (int #open ("i" Int/Number Int/Ord))) bool) meta/macro)) @@ -20,15 +18,6 @@ ## (| #Nil ## (#Cons (, a (List a))))) -(deftype #export (PList k v) - (| (#PList (, (E;Eq k) (List (, k v)))))) - -## [Constructors] -(def #export (plist eq) - (All [k v] - (-> (E;Eq k) (PList k v))) - (#PList [eq #;Nil])) - ## [Functions] (def #export (foldL f init xs) (All [a b] @@ -225,17 +214,19 @@ ## [Syntax] (defmacro #export (list xs state) - (#;Right [state (#;Cons [(foldL (lambda [tail head] - (` (#;Cons [(~ head) (~ tail)]))) - (` #;Nil) + (#;Right [state (#;Cons [(foldL (: (-> AST AST AST) + (lambda [tail head] + (` (#;Cons [(~ head) (~ tail)])))) + (: AST (` #;Nil)) (reverse xs)) #;Nil])])) (defmacro #export (list& xs state) (case (reverse xs) (#;Cons [last init]) - (#;Right [state (list (foldL (lambda [tail head] - (` (#;Cons [(~ head) (~ tail)]))) + (#;Right [state (list (foldL (: (-> AST AST AST) + (lambda [tail head] + (` (#;Cons [(~ head) (~ tail)])))) last init))]) @@ -281,57 +272,6 @@ (using List/Monoid (foldL ++ unit mma)))) -(defstruct #export PList/Dict (Dict PList) - (def (D;get k (#PList [eq kvs])) - (loop [kvs kvs] - (case kvs - #;Nil - #;None - - (#;Cons [k' v'] kvs') - (if (:: eq (E;= k k')) - (#;Some v') - (recur kvs'))))) - - (def (D;put k v (#PList [eq kvs])) - (#PList [eq (loop [kvs kvs] - (case kvs - #;Nil - (#;Cons [k v] kvs) - - (#;Cons [k' v'] kvs') - (if (:: eq (E;= k k')) - (#;Cons [k v] kvs') - (#;Cons [k' v'] (recur kvs')))))])) - - (def (D;remove k (#PList [eq kvs])) - (#PList [eq (loop [kvs kvs] - (case kvs - #;Nil - kvs - - (#;Cons [[k' v'] kvs']) - (if (:: eq (E;= k k')) - kvs' - (#;Cons [[k' v'] (recur kvs')]))))]))) - -(defstruct #export List/Stack (S;Stack List) - (def S;empty (list)) - (def (S;empty? xs) - (case xs - #;Nil true - _ false)) - (def (S;push x xs) - (#;Cons x xs)) - (def (S;pop xs) - (case xs - #;Nil #;None - (#;Cons x xs') (#;Some xs'))) - (def (S;top xs) - (case xs - #;Nil #;None - (#;Cons x xs') (#;Some x)))) - ## [Functions] (def #export (sort ord xs) (All [a] (-> (O;Ord a) (List a) (List a))) diff --git a/source/lux/data/text.lux b/source/lux/data/text.lux index 3801e9675..0040a96c5 100644 --- a/source/lux/data/text.lux +++ b/source/lux/data/text.lux @@ -166,7 +166,7 @@ (defmacro #export (<> tokens state) (case tokens - (\ (list (#;Meta _ (#;TextS template)))) + (\ (list [_ (#;TextS template)])) (let [++ (symbol$ ["" ""])] (#;Right state (list (` (;let [(~ ++) (;:: Text/Monoid m;++)] (;$ (~ ++) (~@ (unravel-template template)))))))) diff --git a/source/lux/host/jvm.lux b/source/lux/host/jvm.lux index 9795965bd..40021d8fa 100644 --- a/source/lux/host/jvm.lux +++ b/source/lux/host/jvm.lux @@ -96,7 +96,7 @@ (list) (#;Some finally) - (list (` (_jvm_finally (~ 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) @@ -166,7 +166,7 @@ (defsyntax #export (.? [field local-symbol^] obj) (case obj - (#;Meta [_ (#;SymbolS obj-name)]) + [_ (#;SymbolS obj-name)] (do Lux/Monad [obj-type (find-var-type obj-name)] (case obj-type @@ -184,7 +184,7 @@ (defsyntax #export (.= [field local-symbol^] value obj) (case obj - (#;Meta [_ (#;SymbolS obj-name)]) + [_ (#;SymbolS obj-name)] (do Lux/Monad [obj-type (find-var-type obj-name)] (case obj-type @@ -203,7 +203,7 @@ (defsyntax #export (.! [call method-call^] obj) (let [[m-name ?m-classes m-args] call] (case obj - (#;Meta [_ (#;SymbolS obj-name)]) + [_ (#;SymbolS obj-name)] (do Lux/Monad [obj-type (find-var-type obj-name)] (case obj-type diff --git a/source/lux/meta/ast.lux b/source/lux/meta/ast.lux index ecf7d6e6e..a601739a1 100644 --- a/source/lux/meta/ast.lux +++ b/source/lux/meta/ast.lux @@ -28,7 +28,7 @@ (do-template [<name> <type> <tag>] [(def #export (<name> x) (-> <type> AST) - (#;Meta _cursor (<tag> x)))] + [_cursor (<tag> x)])] [bool$ Bool #;BoolS] [int$ Int #;IntS] diff --git a/source/lux/meta/lux.lux b/source/lux/meta/lux.lux index 8a0ec5f46..92c43bbee 100644 --- a/source/lux/meta/lux.lux +++ b/source/lux/meta/lux.lux @@ -119,7 +119,7 @@ (def #export (macro-expand syntax) (-> AST (Lux (List AST))) (case syntax - (#;Meta [_ (#;FormS (#;Cons [(#;Meta [_ (#;SymbolS macro-name)]) args]))]) + [_ (#;FormS (#;Cons [[_ (#;SymbolS macro-name)] args]))] (do Lux/Monad [macro-name' (normalize macro-name) ?macro (find-macro macro-name')] @@ -139,7 +139,7 @@ (def #export (macro-expand-all syntax) (-> AST (Lux (List AST))) (case syntax - (#;Meta [_ (#;FormS (#;Cons [(#;Meta [_ (#;SymbolS macro-name)]) args]))]) + [_ (#;FormS (#;Cons [[_ (#;SymbolS macro-name)] args]))] (do Lux/Monad [macro-name' (normalize macro-name) ?macro (find-macro macro-name')] @@ -155,13 +155,13 @@ [parts' (M;map% Lux/Monad macro-expand-all (list& (symbol$ macro-name) args))] (wrap (list (form$ (:: List/Monad (M;join parts')))))))) - (#;Meta [_ (#;FormS (#;Cons [harg targs]))]) + [_ (#;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+)))))))) - (#;Meta [_ (#;TupleS members)]) + [_ (#;TupleS members)] (do Lux/Monad [members' (M;map% Lux/Monad macro-expand-all members)] (wrap (list (tuple$ (:: List/Monad (M;join members')))))) diff --git a/source/lux/meta/macro.lux b/source/lux/meta/macro.lux index bfc274e59..f554f45b4 100644 --- a/source/lux/meta/macro.lux +++ b/source/lux/meta/macro.lux @@ -9,18 +9,18 @@ (def #export (defmacro tokens state) Macro (case tokens - (#;Cons [(#;Meta [_ (#;FormS (#;Cons [name args]))]) (#;Cons [body #;Nil])]) - (#;Right [state (#;Cons [(` ((~ (#;Meta ["" -1 -1] (#;SymbolS ["lux" "def"]))) ((~ name) (~@ args)) - (~ (#;Meta ["" -1 -1] (#;SymbolS ["lux" "Macro"]))) + (#;Cons [[_ (#;FormS (#;Cons [name args]))] (#;Cons [body #;Nil])]) + (#;Right [state (#;Cons [(` ((~ [["" -1 -1] (#;SymbolS ["lux" "def"])]) ((~ name) (~@ args)) + (~ [["" -1 -1] (#;SymbolS ["lux" "Macro"])]) (~ body))) - (#;Cons [(` ((~ (#;Meta ["" -1 -1] (#;SymbolS ["" "_lux_declare-macro"]))) (~ name))) + (#;Cons [(` ((~ [["" -1 -1] (#;SymbolS ["" "_lux_declare-macro"])]) (~ name))) #;Nil])])]) - (#;Cons [(#;Meta [_ (#;TagS ["" "export"])]) (#;Cons [(#;Meta [_ (#;FormS (#;Cons [name args]))]) (#;Cons [body #;Nil])])]) - (#;Right [state (#;Cons [(` ((~ (#;Meta ["" -1 -1] (#;SymbolS ["lux" "def"]))) (~ (#;Meta ["" -1 -1] (#;TagS ["" "export"]))) ((~ name) (~@ args)) - (~ (#;Meta ["" -1 -1] (#;SymbolS ["lux" "Macro"]))) + (#;Cons [[_ (#;TagS ["" "export"])] (#;Cons [[_ (#;FormS (#;Cons [name args]))] (#;Cons [body #;Nil])])]) + (#;Right [state (#;Cons [(` ((~ [["" -1 -1] (#;SymbolS ["lux" "def"])]) (~ [["" -1 -1] (#;TagS ["" "export"])]) ((~ name) (~@ args)) + (~ [["" -1 -1] (#;SymbolS ["lux" "Macro"])]) (~ body))) - (#;Cons [(` ((~ (#;Meta ["" -1 -1] (#;SymbolS ["" "_lux_declare-macro"]))) (~ name))) + (#;Cons [(` ((~ [["" -1 -1] (#;SymbolS ["" "_lux_declare-macro"])]) (~ name))) #;Nil])])]) _ diff --git a/source/lux/meta/syntax.lux b/source/lux/meta/syntax.lux index c7f691389..1732350ce 100644 --- a/source/lux/meta/syntax.lux +++ b/source/lux/meta/syntax.lux @@ -70,7 +70,7 @@ [(def #export (<name> tokens) (Parser <type>) (case tokens - (#;Cons [(#;Meta [_ (<tag> x)]) tokens']) + (#;Cons [[_ (<tag> x)] tokens']) (#;Some [tokens' x]) _ @@ -89,7 +89,7 @@ [(def #export (<name> tokens) (Parser Text) (case tokens - (#;Cons [(#;Meta [_ (<tag> ["" x])]) tokens']) + (#;Cons [[_ (<tag> ["" x])] tokens']) (#;Some [tokens' x]) _ @@ -110,7 +110,7 @@ [(def #export (<name> v tokens) (-> <type> (Parser (,))) (case tokens - (#;Cons [(#;Meta [_ (<tag> x)]) tokens']) + (#;Cons [[_ (<tag> x)] tokens']) (if (<eq> v x) (#;Some [tokens' []]) #;None) @@ -132,7 +132,7 @@ (All [a] (-> (Parser a) (Parser a))) (case tokens - (#;Cons [(#;Meta [_ (<tag> form)]) tokens']) + (#;Cons [[_ (<tag> form)] tokens']) (case (p form) (#;Some [#;Nil x]) (#;Some [tokens' x]) _ #;None) @@ -212,24 +212,24 @@ (defmacro #export (defsyntax tokens) (let [[exported? tokens] (: (, Bool (List AST)) (case tokens - (\ (list& (#;Meta [_ (#;TagS ["" "export"])]) tokens')) + (\ (list& [_ (#;TagS ["" "export"])] tokens')) [true tokens'] _ [false tokens]))] (case tokens - (\ (list (#;Meta [_ (#;FormS (list& (#;Meta [_ (#;SymbolS ["" name])]) args))]) + (\ (list [_ (#;FormS (list& [_ (#;SymbolS ["" name])] args))] body)) (do Lux/Monad [names+parsers (M;map% Lux/Monad (: (-> AST (Lux (, AST AST))) (lambda [arg] (case arg - (\ (#;Meta [_ (#;TupleS (list (#;Meta [_ (#;SymbolS var-name)]) - parser))])) + (\ [_ (#;TupleS (list [_ (#;SymbolS var-name)] + parser))]) (wrap [(symbol$ var-name) parser]) - (\ (#;Meta [_ (#;SymbolS var-name)])) + (\ [_ (#;SymbolS var-name)]) (wrap [(symbol$ var-name) (` id^)]) _ |