aboutsummaryrefslogtreecommitdiff
path: root/source/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'source/lux.lux')
-rw-r--r--source/lux.lux41
1 files changed, 32 insertions, 9 deletions
diff --git a/source/lux.lux b/source/lux.lux
index ddb3384cc..4d1c3fdef 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -5,7 +5,7 @@
## First things first, must define functions
(_jvm_interface "Function" [] []
- ("apply" ["public" "abstract"] [] [] ["java.lang.Object"] "java.lang.Object"))
+ ("apply" ["public" "abstract"] [] [] ["java.lang.Object"] "java.lang.Object"))
## Basic types
(_lux_def Bool (10 ["lux" "Bool"]
@@ -394,6 +394,11 @@
(_lux_export DefData)
(_lux_declare-tags [#ValueD #TypeD #MacroD #AliasD] DefData)
+(_lux_def Definition
+ (#NamedT ["lux" "Definition"]
+ (#AppT (#AppT Meta Bool) DefData)))
+(_lux_export Definition)
+
## Base functions & macros
## (def _cursor
## Cursor
@@ -1060,8 +1065,9 @@
## (-> Compiler (Either Text (, Compiler a))))
(def''' #export Lux
Type
- (All [a]
- (-> Compiler ($' Either Text (, Compiler a)))))
+ (#NamedT ["lux" "Lux"]
+ (All [a]
+ (-> Compiler ($' Either Text (, Compiler a))))))
## (defsig (Monad m)
## (: (All [a] (-> a (m a)))
@@ -1405,6 +1411,15 @@
_
#None))
+(def''' (get-tag x)
+ (-> AST ($' Maybe Ident))
+ (_lux_case x
+ [_ (#TagS sname)]
+ (#Some sname)
+
+ _
+ #None))
+
(def''' (get-name x)
(-> AST ($' Maybe Text))
(_lux_case x
@@ -1535,7 +1550,7 @@
[$module (get module modules)
gdef (let' [{#module-aliases _ #defs bindings #imports _ #tags tags #types types} (_lux_: ($' Module Compiler) $module)]
(get name bindings))]
- (_lux_case (_lux_: (, Bool DefData) gdef)
+ (_lux_case (_lux_: Definition gdef)
[exported? (#MacroD macro')]
(if exported?
(#Some macro')
@@ -2023,7 +2038,7 @@
(if (symbol? arg)
(` (;_lux_lambda (~ g!blank) (~ arg) (~ body')))
(` (;_lux_lambda (~ g!blank) (~ g!blank)
- (case (~ g!blank) (~ arg) (~ body')))))))
+ (case (~ g!blank) (~ arg) (~ body')))))))
body
(reverse tail))]
(return (@list (if (symbol? head)
@@ -2616,7 +2631,7 @@
#cursor cursor}
(case (get module modules)
(#Some =module)
- (let [to-alias (map (: (-> (, Text (, Bool DefData))
+ (let [to-alias (map (: (-> (, Text Definition)
(List Text))
(lambda [gdef]
(let [[name [export? _]] gdef]
@@ -3226,7 +3241,7 @@
(return (@list (` ((: (-> (~@ (map type->ast init-types))
(~ (type->ast expected)))
(lambda (~ (symbol$ ["" "recur"])) [(~@ vars)]
- (~ body)))
+ (~ body)))
(~@ inits))))))
(do Lux/Monad
[aliases (map% Lux/Monad
@@ -3250,8 +3265,8 @@
[slots (: (Lux (, Ident (List Ident)))
(case (: (Maybe (, Ident (List Ident)))
(do Maybe/Monad
- [hslot (get-ident hslot')
- tslots (map% Maybe/Monad get-ident tslots')]
+ [hslot (get-tag hslot')
+ tslots (map% Maybe/Monad get-tag tslots')]
(wrap [hslot tslots])))
(#Some slots)
(return slots)
@@ -3278,3 +3293,11 @@
_
(fail "Wrong syntax for \\slots")))
+
+(do-template [<name> <diff>]
+ [(def #export <name>
+ (-> Int Int)
+ (i+ <diff>))]
+
+ [inc 1]
+ [dec -1])