aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/lux.lux425
1 files changed, 218 insertions, 207 deletions
diff --git a/source/lux.lux b/source/lux.lux
index d3ed0c3a3..9a0bab625 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -23,17 +23,21 @@
## this [arg1 arg2]) [arg3]))]))
## Base functions & macros
+(def' _meta
+ (lambda' _ data
+ (#Meta [["" -1 -1] data])))
+
(def' let'
(lambda' _ tokens
(lambda' _ state
(case' tokens
(#Cons [lhs (#Cons [rhs (#Cons [body #Nil])])])
(#Right [state
- (#Cons [(#Form (#Cons [(#Symbol ["" "case'"])
- (#Cons [rhs
- (#Cons [lhs
- (#Cons [body
- #Nil])])])]))
+ (#Cons [(_meta (#Form (#Cons [(_meta (#Symbol ["" "case'"]))
+ (#Cons [rhs
+ (#Cons [lhs
+ (#Cons [body
+ #Nil])])])])))
#Nil])]))
)))
(declare-macro let')
@@ -42,33 +46,33 @@
(lambda' _ tokens
(lambda' _ state
(let' output (case' tokens
- (#Cons [(#Tuple (#Cons [arg args'])) (#Cons [body #Nil])])
- (#Form (#Cons [(#Symbol ["" "lambda'"])
- (#Cons [(#Symbol ["" ""])
- (#Cons [arg
- (#Cons [(case' args'
- #Nil
- body
-
- _
- (#Form (#Cons [(#Symbol ["lux" "lambda"])
- (#Cons [(#Tuple args')
- (#Cons [body #Nil])])])))
- #Nil])])])]))
-
- (#Cons [(#Symbol self) (#Cons [(#Tuple (#Cons [arg args'])) (#Cons [body #Nil])])])
- (#Form (#Cons [(#Symbol ["" "lambda'"])
- (#Cons [(#Symbol self)
- (#Cons [arg
- (#Cons [(case' args'
- #Nil
- body
-
- _
- (#Form (#Cons [(#Symbol ["lux" "lambda"])
- (#Cons [(#Tuple args')
- (#Cons [body #Nil])])])))
- #Nil])])])])))
+ (#Cons [(#Meta [_ (#Tuple (#Cons [arg args']))]) (#Cons [body #Nil])])
+ (_meta (#Form (#Cons [(_meta (#Symbol ["" "lambda'"]))
+ (#Cons [(_meta (#Symbol ["" ""]))
+ (#Cons [arg
+ (#Cons [(case' args'
+ #Nil
+ body
+
+ _
+ (_meta (#Form (#Cons [(_meta (#Symbol ["lux" "lambda"]))
+ (#Cons [(_meta (#Tuple args'))
+ (#Cons [body #Nil])])]))))
+ #Nil])])])])))
+
+ (#Cons [(#Meta [_ (#Symbol self)]) (#Cons [(#Meta [_ (#Tuple (#Cons [arg args']))]) (#Cons [body #Nil])])])
+ (_meta (#Form (#Cons [(_meta (#Symbol ["" "lambda'"]))
+ (#Cons [(_meta (#Symbol self))
+ (#Cons [arg
+ (#Cons [(case' args'
+ #Nil
+ body
+
+ _
+ (_meta (#Form (#Cons [(_meta (#Symbol ["lux" "lambda"]))
+ (#Cons [(_meta (#Tuple args'))
+ (#Cons [body #Nil])])]))))
+ #Nil])])])]))))
(#Right [state (#Cons [output #Nil])]))
)))
(declare-macro lambda)
@@ -76,31 +80,31 @@
(def' def
(lambda [tokens state]
(let' output (case' tokens
- (#Cons [(#Symbol name) (#Cons [body #Nil])])
- (#Form (#Cons [(#Symbol ["" "def'"]) tokens]))
+ (#Cons [(#Meta [_ (#Symbol name)]) (#Cons [body #Nil])])
+ (_meta (#Form (#Cons [(_meta (#Symbol ["" "def'"])) tokens])))
- (#Cons [(#Form (#Cons [(#Symbol name) args]))
+ (#Cons [(#Meta [_ (#Form (#Cons [(#Meta [_ (#Symbol name)]) args]))])
(#Cons [body #Nil])])
- (#Form (#Cons [(#Symbol ["" "def'"])
- (#Cons [(#Symbol name)
- (#Cons [(#Form (#Cons [(#Symbol ["lux" "lambda"])
- (#Cons [(#Symbol name)
- (#Cons [(#Tuple args)
- (#Cons [body #Nil])])])]))
- #Nil])])])))
+ (_meta (#Form (#Cons [(_meta (#Symbol ["" "def'"]))
+ (#Cons [(_meta (#Symbol name))
+ (#Cons [(_meta (#Form (#Cons [(_meta (#Symbol ["lux" "lambda"]))
+ (#Cons [(_meta (#Symbol name))
+ (#Cons [(_meta (#Tuple args))
+ (#Cons [body #Nil])])])])))
+ #Nil])])]))))
(#Right [state (#Cons [output #Nil])]))))
(declare-macro def)
(def (defmacro tokens state)
(let' [fn-name fn-def] (case' tokens
- (#Cons [(#Form (#Cons [(#Symbol fn-name) args]))
+ (#Cons [(#Meta [_ (#Form (#Cons [(#Meta [_ (#Symbol fn-name)]) args]))])
(#Cons [body #Nil])])
[fn-name
- (#Form (#Cons [(#Symbol ["lux" "def"])
- (#Cons [(#Form (#Cons [(#Symbol fn-name) args]))
- (#Cons [body
- #Nil])])]))])
- (let' declaration (#Form (#Cons [(#Symbol ["" "declare-macro"]) (#Cons [(#Symbol fn-name) #Nil])]))
+ (_meta (#Form (#Cons [(_meta (#Symbol ["lux" "def"]))
+ (#Cons [(_meta (#Form (#Cons [(_meta (#Symbol fn-name)) args])))
+ (#Cons [body
+ #Nil])])])))])
+ (let' declaration (_meta (#Form (#Cons [(_meta (#Symbol ["" "declare-macro"])) (#Cons [(_meta (#Symbol fn-name)) #Nil])])))
(#Right [state (#Cons [fn-def (#Cons [declaration #Nil])])]))))
(declare-macro defmacro)
@@ -138,10 +142,10 @@
(defmacro (list xs state)
(let' xs' (reverse xs)
(let' output (fold (lambda [tail head]
- (#Form (#Cons [(#Tag ["lux" "Cons"])
- (#Cons [(#Tuple (#Cons [head (#Cons [tail #Nil])]))
- #Nil])])))
- (#Tag ["lux" "Nil"])
+ (_meta (#Form (#Cons [(_meta (#Tag ["lux" "Cons"]))
+ (#Cons [(_meta (#Tuple (#Cons [head (#Cons [tail #Nil])])))
+ #Nil])]))))
+ (_meta (#Tag ["lux" "Nil"]))
xs')
(#Right [state (#Cons [output #Nil])]))))
@@ -152,7 +156,7 @@
(#Cons [last init'])
(let' output (fold (lambda [tail head]
- (#Form (list (#Tag ["lux" "Cons"]) (#Tuple (list head tail)))))
+ (_meta (#Form (list (_meta (#Tag ["lux" "Cons"])) (_meta (#Tuple (list head tail)))))))
last
init')
(#Right [state (#Cons [output #Nil])]))))
@@ -167,11 +171,11 @@
(defmacro (let tokens state)
(case' tokens
- (#Cons [(#Tuple bindings) (#Cons [body #Nil])])
+ (#Cons [(#Meta [_ (#Tuple bindings)]) (#Cons [body #Nil])])
(let' output (fold (lambda [body binding]
(case' binding
[label value]
- (#Form (list (#Symbol ["lux" "let'"]) label value body))))
+ (_meta (#Form (list (_meta (#Symbol ["lux" "let'"])) label value body)))))
body
(reverse (as-pairs bindings)))
(#Right [state (list output)]))))
@@ -184,8 +188,8 @@
#Nil
ys
- (#Cons [x xs*])
- (#Cons [x (++ xs* ys)])))
+ (#Cons [x xs'])
+ (#Cons [x (++ xs' ys)])))
(def concat
(fold ++ #Nil))
@@ -200,47 +204,53 @@
(def flat-map (. concat map))
+(def (wrap-meta content)
+ (_meta (#Form (list (_meta (#Tag ["lux" "Meta"]))
+ (_meta (#Tuple (list (_meta (#Tuple (list (_meta (#Form (list (_meta (#Tag ["lux" "Text"])) (_meta (#Text "")))))
+ (_meta (#Form (list (_meta (#Tag ["lux" "Int"])) (_meta (#Int -1)))))
+ (_meta (#Form (list (_meta (#Tag ["lux" "Int"])) (_meta (#Int -1))))))))
+ (_meta content))))))))
+
(def (untemplate-list tokens)
(case' tokens
#Nil
- (#Tag ["lux" "Nil"])
+ (_meta (#Tag ["lux" "Nil"]))
(#Cons [token tokens'])
- (#Form (#Cons [(#Tag ["lux" "Cons"])
- (#Cons [(#Tuple (#Cons [token (#Cons [(untemplate-list tokens') #Nil])]))
- #Nil])]))))
+ (_meta (#Form (list (_meta (#Tag ["lux" "Cons"]))
+ (_meta (#Tuple (list token (untemplate-list tokens')))))))))
(def (untemplate token)
(case' token
- (#Bool value)
- (#Form (list (#Tag ["lux" "Bool"]) (#Bool value)))
-
- (#Int value)
- (#Form (list (#Tag ["lux" "Int"]) (#Int value)))
+ (#Meta [_ (#Bool value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Bool"])) (_meta (#Bool value)))))
+
+ (#Meta [_ (#Int value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Int"])) (_meta (#Int value)))))
- (#Real value)
- (#Form (list (#Tag ["lux" "Real"]) (#Real value)))
+ (#Meta [_ (#Real value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Real"])) (_meta (#Real value)))))
- (#Char value)
- (#Form (list (#Tag ["lux" "Char"]) (#Char value)))
+ (#Meta [_ (#Char value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Char"])) (_meta (#Char value)))))
- (#Text value)
- (#Form (list (#Tag ["lux" "Text"]) (#Text value)))
+ (#Meta [_ (#Text value)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Text"])) (_meta (#Text value)))))
- (#Tag [module name])
- (#Form (list (#Tag ["lux" "Tag"]) (#Tuple (list (#Text module) (#Text name)))))
+ (#Meta [_ (#Tag [module name])])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Tag"])) (_meta (#Tuple (list (_meta (#Text module)) (_meta (#Text name))))))))
- (#Symbol [module name])
- (#Form (list (#Tag ["lux" "Symbol"]) (#Tuple (list (#Text module) (#Text name)))))
+ (#Meta [_ (#Symbol [module name])])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Symbol"])) (_meta (#Tuple (list (_meta (#Text module)) (_meta (#Text name))))))))
- (#Tuple elems)
- (#Form (list (#Tag ["lux" "Tuple"]) (untemplate-list (map untemplate elems))))
+ (#Meta [_ (#Tuple elems)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Tuple"])) (untemplate-list (map untemplate elems)))))
- (#Form (#Cons [(#Symbol [_ "~"]) (#Cons [unquoted #Nil])]))
- unquoted
+ (#Meta [_ (#Form (#Cons [(#Meta [_ (#Symbol [_ "~"])]) (#Cons [(#Meta [_ unquoted]) #Nil])]))])
+ (_meta unquoted)
- (#Form elems)
- (#Form (list (#Tag ["lux" "Form"]) (untemplate-list (map untemplate elems))))
+ (#Meta [_ (#Form elems)])
+ (wrap-meta (#Form (list (_meta (#Tag ["lux" "Form"])) (untemplate-list (map untemplate elems)))))
))
(defmacro (` tokens state)
@@ -261,10 +271,10 @@
#Nil
#Nil
- (#Cons [x xs*])
+ (#Cons [x xs'])
(if (p x)
- (filter p xs*)
- (#Cons [x (filter p xs*)]))))
+ (#Cons [x (filter p xs')])
+ (filter p xs'))))
(def (return val)
(lambda [state]
@@ -279,7 +289,7 @@
(case' (v state)
(#Right [state' x])
(f x state')
-
+
(#Left msg)
(#Left msg))))
@@ -416,7 +426,7 @@
(case' xs
#Nil
xs
-
+
(#Cons [x #Nil])
xs
@@ -428,14 +438,14 @@
#Nil true
_ false))
-## ## (do-template [<name> <op>]
-## ## (def (<name> p xs)
-## ## (case xs
-## ## #Nil true
-## ## (#Cons [x xs']) (<op> (p x) (<name> p xs'))))
+## ## ## (do-template [<name> <op>]
+## ## ## (def (<name> p xs)
+## ## ## (case xs
+## ## ## #Nil true
+## ## ## (#Cons [x xs']) (<op> (p x) (<name> p xs'))))
-## ## [every? and]
-## ## [any? or])
+## ## ## [every? and]
+## ## ## [any? or])
(def (range from to)
(if (int< from to)
@@ -444,7 +454,7 @@
(def (tuple->list tuple)
(case' tuple
- (#Tuple list)
+ (#Meta [_ (#Tuple list)])
list))
(def (zip2 xs ys)
@@ -468,7 +478,7 @@
(def (get-ident x)
(case' x
- (#Symbol [_ ident])
+ (#Meta [_ (#Symbol [_ ident])])
ident))
(def (text-++ x y)
@@ -480,26 +490,26 @@
(def (apply-template env template)
(case' template
- (#Symbol [_ ident])
+ (#Meta [_ (#Symbol [_ ident])])
(case' (get ident env)
(#Some subst)
subst
_
template)
-
- (#Tuple elems)
- (#Tuple (map (apply-template env) elems))
- (#Form elems)
- (#Form (map (apply-template env) elems))
+ (#Meta [_ (#Tuple elems)])
+ (_meta (#Tuple (map (apply-template env) elems)))
+
+ (#Meta [_ (#Form elems)])
+ (_meta (#Form (map (apply-template env) elems)))
- (#Record members)
- (#Record (map (lambda [kv]
- (case' kv
- [slot value]
- [(apply-template env slot) (apply-template env value)]))
- members))
+ (#Meta [_ (#Record members)])
+ (_meta (#Record (map (lambda [kv]
+ (case' kv
+ [slot value]
+ [(apply-template env slot) (apply-template env value)]))
+ members)))
_
template))
@@ -514,11 +524,11 @@
(map (. apply (zip2 bindings-list)))
return))))
-## ## (do-template [<name> <offset>]
-## ## (def <name> (int+ <offset>))
+## ## ## (do-template [<name> <offset>]
+## ## ## (def <name> (int+ <offset>))
-## ## [inc 1]
-## ## [dec -1])
+## ## ## [inc 1]
+## ## ## [dec -1])
(def (int= x y)
(jvm-leq x y))
@@ -611,58 +621,58 @@
(jvm-invokevirtual java.lang.Object "toString" []
int []))
-## ## (def gensym
-## ## (lambda [state]
-## ## [(update@ #gen-seed inc state)
-## ## (#Symbol ($ text-++ "__" (show-int (get@ #gen-seed state)) "__"))]))
+## (def gensym
+## (lambda [state]
+## [(update@ #gen-seed inc state)
+## (#Symbol ($ text-++ "__" (show-int (get@ #gen-seed state)) "__"))]))
-## ## ## (do-template [<name> <member>]
-## ## ## (def (<name> pair)
-## ## ## (case' pair
-## ## ## [f s]
-## ## ## <member>))
+## (do-template [<name> <member>]
+## (def (<name> pair)
+## (case' pair
+## [f s]
+## <member>))
-## ## ## [first f]
-## ## ## [second s])
+## [first f]
+## [second s])
(def (show-syntax syntax)
(case' syntax
- (#Bool value)
+ (#Meta [_ (#Bool value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
-
- (#Int value)
+
+ (#Meta [_ (#Int value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
-
- (#Real value)
+
+ (#Meta [_ (#Real value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
-
- (#Char value)
+
+ (#Meta [_ (#Char value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
-
- (#Text value)
+
+ (#Meta [_ (#Text value)])
(jvm-invokevirtual java.lang.Object "toString" []
value [])
- (#Symbol [module name])
+ (#Meta [_ (#Symbol [module name])])
($ text-++ module ";" name)
- (#Tag [module name])
+ (#Meta [_ (#Tag [module name])])
($ text-++ "#" module ";" name)
- (#Tuple members)
+ (#Meta [_ (#Tuple members)])
($ text-++ "[" (fold text-++ "" (interpose " " (map show-syntax members))) "]")
-
- (#Form members)
+
+ (#Meta [_ (#Form members)])
($ text-++ "(" (fold text-++ "" (interpose " " (map show-syntax members))) ")")
))
(defmacro (do tokens)
(case' tokens
- (#Cons [(#Tuple bindings) (#Cons [body #Nil])])
+ (#Cons [(#Meta [_ (#Tuple bindings)]) (#Cons [body #Nil])])
(let [output (fold (lambda [body binding]
(case' binding
[lhs rhs]
@@ -684,16 +694,16 @@
(defmacro ($keys tokens)
(case' tokens
- (#Cons [(#Tuple fields) #Nil])
- (return (list (#Record (map (lambda [slot]
- (case' slot
- (#Tag [module name])
- [($ text-++ module ";" name) (#Symbol [module name])]))
- fields))))))
+ (#Cons [(#Meta [_ (#Tuple fields)]) #Nil])
+ (return (list (_meta (#Record (map (lambda [slot]
+ (case' slot
+ (#Meta [_ (#Tag [module name])])
+ [($ text-++ module ";" name) (_meta (#Symbol [module name]))]))
+ fields)))))))
(defmacro ($or tokens)
(case' tokens
- (#Cons [(#Tuple patterns) (#Cons [body #Nil])])
+ (#Cons [(#Meta [_ (#Tuple patterns)]) (#Cons [body #Nil])])
(return (flat-map (lambda [pattern] (list pattern body))
patterns))))
@@ -701,40 +711,41 @@
(defmacro (^ tokens)
(case' tokens
- (#Cons [(#Symbol [_ class-name]) #Nil])
- (return (list (` (#Data [(~ (#Text class-name)) (list)]))))
-
- (#Cons [(#Symbol [_ class-name]) (#Cons [(#Tuple params) #Nil])])
- (return (list (` (#Data [(~ (#Text class-name)) (~ (untemplate-list params))]))))))
+ (#Cons [(#Meta [_ (#Symbol [_ class-name])]) #Nil])
+ (return (list (` (#TData [(~ (_meta (#Text class-name))) (list)]))))
+
+ (#Cons [(#Meta [_ (#Symbol [_ class-name])]) (#Cons [(#Meta [_ (#Tuple params)]) #Nil])])
+ (return (list (` (#TData [(~ (_meta (#Text class-name))) (~ (untemplate-list params))]))))))
(defmacro (, members)
- (return (list (#Form (list+ (#Tag ["lux" "TTuple"]) (untemplate-list members))))))
+ (return (list (_meta (#Form (list+ (_meta (#Tag ["lux" "TTuple"])) (untemplate-list members)))))))
(defmacro (| members)
(let [members' (map (lambda [m]
(case' m
- (#Tag [module name])
+ (#Meta [_ (#Tag [module name])])
[($ text-++ module ";" name) (` (#Tuple (list)))]
-
- (#Form (#Cons [(#Tag [module name]) (#Cons [value #Nil])]))
+
+ (#Meta [_ (#Form (#Cons [(#Meta [_ (#Tag [module name])]) (#Cons [value #Nil])]))])
[($ text-++ module ";" name) (` (#Tuple (~ value)))]))
members)]
- (return (list (#Form (list+ (#Tag ["lux" "TVariant"]) (untemplate-list members)))))))
+ (return (list (_meta (#Form (list+ (_meta (#Tag ["lux" "TVariant"])) (untemplate-list members))))))))
(defmacro (& members)
(let [members' (map (lambda [m]
(case' m
- (#Form (#Cons [(#Tag [module name]) (#Cons [value #Nil])]))
+ (#Meta [_ (#Form (#Cons [(#Meta [_ (#Tag [module name])]) (#Cons [value #Nil])]))])
[($ text-++ module ";" name) (` (#Tuple (~ value)))]))
members)]
- (return (list (#Form (list+ (#Tag ["lux" "TRecord"]) (untemplate-list members)))))))
+ (return (list (_meta (#Form (list+ (_meta (#Tag ["lux" "TRecord"])) (untemplate-list members))))))))
(defmacro (-> tokens)
(case' (reverse tokens)
(#Cons [f-return f-args])
(fold (lambda [f-return f-arg]
- (#Lambda [f-arg f-return]))
- f-return f-args)))
+ (` (#TLambda [(~ f-arg) (~ f-return)])))
+ f-return
+ f-args)))
(def (text= x y)
(jvm-invokevirtual java.lang.Object "equals" [java.lang.Object]
@@ -743,56 +754,56 @@
(def (replace-ident ident value syntax)
(let [[module name] ident]
(case' syntax
- (#Symbol [?module ?name])
+ (#Meta [_ (#Symbol [?module ?name])])
(if (and (text= module ?module)
(text= name ?name))
value
syntax)
- (#Form members)
- (#Form (map (replace-ident ident value) members))
+ (#Meta [_ (#Form members)])
+ (_meta (#Form (map (replace-ident ident value) members)))
- (#Tuple members)
- (#Tuple (map (replace-ident ident value) members))
+ (#Meta [_ (#Tuple members)])
+ (_meta (#Tuple (map (replace-ident ident value) members)))
- (#Record members)
- (#Record (map (lambda [kv]
- (case' kv
- [k v]
- [k (replace-ident ident value v)]))
- members))
+ (#Meta [_ (#Record members)])
+ (_meta (#Record (map (lambda [kv]
+ (case' kv
+ [k v]
+ [k (replace-ident ident value v)]))
+ members)))
_
syntax)))
(defmacro (All tokens)
(let [[name args body] (case' tokens
- (#Cons [(#Symbol [_ name]) (#Cons [(#Tuple args) (#Cons [body #Nil])])])
+ (#Cons [(#Meta [_ (#Symbol [_ name])]) (#Cons [(#Meta [_ (#Tuple args)]) (#Cons [body #Nil])])])
[name args body]
-
- (#Cons [(#Tuple args) (#Cons [body #Nil])])
+
+ (#Cons [(#Meta [_ (#Tuple args)]) (#Cons [body #Nil])])
["" args body])
rolled (fold (lambda [body arg]
(case' arg
- (#Symbol [arg-module arg-name])
- (` (#All (list) (~ (#Text "")) (~ (#Text arg-name)) (~ (replace-ident [arg-module arg-name]
- (` (#Bound (~ (#Text arg-name))))
- body))))))
+ (#Meta [_ (#Symbol [arg-module arg-name])])
+ (` (#TAll (list) "" (~ (_meta (#Text arg-name))) (~ (replace-ident [arg-module arg-name]
+ (` (#TBound (~ (#Text arg-name))))
+ body))))))
body
args)]
(case' rolled
- (#Form (#Cons [(#Tag ["lux" "TAll"]) (#Cons [env (#Cons [(#Test "") (#Cons [(#Text arg-name) (#Cons [body #Nil])])])])]))
- (return (list (` (#All (~ env) (~ (#Text name)) (~ (#Text arg-name))
- (~ (replace-ident arg-name (` (#Bound (~ (#Text name))))
- body)))))))))
+ (#Meta [_ (#Form (#Cons [(#Meta [_ (#Tag ["lux" "TAll"])]) (#Cons [env (#Cons [(#Meta [_ (#Text "")]) (#Cons [(#Meta [_ (#Text arg-name)]) (#Cons [body #Nil])])])])]))])
+ (return (list (` (#TAll (~ env) (~ (#Text name)) (~ (#Text arg-name))
+ (~ (replace-ident arg-name (` (#TBound (~ (#Text name))))
+ body)))))))))
(defmacro (Exists tokens)
(case' tokens
(#Cons [args (#Cons [body #Nil])])
(return (list (` (All (~ args) (~ body)))))))
-(def Any #Any)
-(def Nothing #Nothing)
+(def Any #TAny)
+(def Nothing #TNothing)
(def Bool (^ java.lang.Boolean))
(def Int (^ java.lang.Long))
(def Real (^ java.lang.Double))
@@ -804,17 +815,17 @@
## (#Cons (, a (List a)))))
## (deftype #rec Type
-## (| #Any
-## #Nothing
-## (#Data Text)
-## (#Tuple (List Type))
-## (#Variant (List (, Text Type)))
-## (#Record (List (, Text Type)))
-## (#Lambda (, Type Type))
-## (#Bound Text)
-## (#Var Int)
-## (#All (, (List (, Text Type)) Text Text Type))
-## (#App (, Type Type))))
+## (| #TAny
+## #TNothing
+## (#TData Text)
+## (#TTuple (List Type))
+## (#TVariant (List (, Text Type)))
+## (#TRecord (List (, Text Type)))
+## (#TLambda (, Type Type))
+## (#TBound Text)
+## (#TVar Int)
+## (#TAll (, (List (, Text Type)) Text Text Type))
+## (#TApp (, Type Type))))
## (deftype (Either l r)
## (| (#Left l)
@@ -929,20 +940,20 @@
## (= x y)))
## (zip2 xs ys)))))
-## ## (def (with tokens)
-## ## ...)
+## (def (with tokens)
+## ...)
-## ## TODO: Full pattern-matching
-## ## TODO: Type-related macros
-## ## TODO: (Im|Ex)ports-related macros
-## ## TODO: Macro-related macros
+## TODO: Full pattern-matching
+## TODO: Type-related macros
+## TODO: (Im|Ex)ports-related macros
+## TODO: Macro-related macros
-## ## (import "lux")
-## ## (module-alias "lux" "l")
-## ## (def-alias "lux;map" "map")
+## (import "lux")
+## (module-alias "lux" "l")
+## (def-alias "lux;map" "map")
-## ## (def (require tokens)
-## ## (case tokens
-## ## ...))
+## (def (require tokens)
+## (case tokens
+## ...))
-## ## (require lux #as l #refer [map])
+## (require lux #as l #refer [map])