aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/lux.lux86
-rw-r--r--src/lux/analyser/case.clj2
-rw-r--r--src/lux/analyser/host.clj3
-rw-r--r--src/lux/host.clj2
-rw-r--r--src/lux/type.clj50
5 files changed, 72 insertions, 71 deletions
diff --git a/source/lux.lux b/source/lux.lux
index ee01c8bdf..4571529a0 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -49,8 +49,8 @@
(1 (1 ## "lux;Nil"
(2 (0))
(1 ## "lux;Cons"
- (2 (1 (4 1)
- (1 (9 (4 0) (4 1))
+ (2 (1 (4 0)
+ (1 (9 (4 1) (4 0))
(0))))
(0)))))))
(_lux_export List)
@@ -65,7 +65,7 @@
(1 (1 ## "lux;None"
(2 (0))
(1 ## "lux;Some"
- (4 1)
+ (4 0)
(0)))))))
(_lux_export Maybe)
(_lux_declare-tags [#None #Some] Maybe)
@@ -84,7 +84,7 @@
## ))
(_lux_def Type
(10 ["lux" "Type"]
- (_lux_case (9 (4 0) (4 1))
+ (_lux_case (9 (4 1) (4 0))
Type
(_lux_case (9 List Type)
TypeList
@@ -127,8 +127,8 @@
Int
(#Cons ## "lux;mappings"
(#AppT List
- (#TupleT (#Cons (#BoundT 3)
- (#Cons (#BoundT 1)
+ (#TupleT (#Cons (#BoundT 2)
+ (#Cons (#BoundT 0)
#Nil))))
#Nil)))))))
(_lux_export Bindings)
@@ -148,11 +148,11 @@
(#Cons ## "lux;inner-closures"
Int
(#Cons ## "lux;locals"
- (#AppT (#AppT Bindings (#BoundT 3))
- (#BoundT 1))
+ (#AppT (#AppT Bindings (#BoundT 2))
+ (#BoundT 0))
(#Cons ## "lux;closure"
- (#AppT (#AppT Bindings (#BoundT 3))
- (#BoundT 1))
+ (#AppT (#AppT Bindings (#BoundT 2))
+ (#BoundT 0))
#Nil)))))))))
(_lux_export Env)
(_lux_declare-tags [#name #inner-closures #locals #closure] Env)
@@ -174,8 +174,8 @@
(#NamedT ["lux" "Meta"]
(#UnivQ #Nil
(#UnivQ #Nil
- (#TupleT (#Cons (#BoundT 3)
- (#Cons (#BoundT 1)
+ (#TupleT (#Cons (#BoundT 2)
+ (#Cons (#BoundT 0)
#Nil)))))))
(_lux_export Meta)
(_lux_declare-tags [#meta #datum] Meta)
@@ -193,9 +193,9 @@
## (#RecordS (List (, (w (AST' w)) (w (AST' w)))))))
(_lux_def AST'
(#NamedT ["lux" "AST'"]
- (_lux_case (#AppT (#BoundT 1)
- (#AppT (#BoundT 0)
- (#BoundT 1)))
+ (_lux_case (#AppT (#BoundT 0)
+ (#AppT (#BoundT 1)
+ (#BoundT 0)))
AST
(_lux_case (#AppT [List AST])
ASTList
@@ -245,9 +245,9 @@
(#UnivQ #Nil
(#UnivQ #Nil
(#VariantT (#Cons ## "lux;Left"
- (#BoundT 3)
+ (#BoundT 2)
(#Cons ## "lux;Right"
- (#BoundT 1)
+ (#BoundT 0)
#Nil)))))))
(_lux_export Either)
(_lux_declare-tags [#Left #Right] Either)
@@ -257,10 +257,10 @@
(_lux_def StateE
(#UnivQ #Nil
(#UnivQ #Nil
- (#LambdaT (#BoundT 3)
+ (#LambdaT (#BoundT 2)
(#AppT (#AppT Either Text)
- (#TupleT (#Cons (#BoundT 3)
- (#Cons (#BoundT 1)
+ (#TupleT (#Cons (#BoundT 2)
+ (#Cons (#BoundT 0)
#Nil))))))))
## (deftype Source
@@ -303,7 +303,7 @@
(#Cons ## "lux;TypeD"
Type
(#Cons ## "lux;MacroD"
- (#BoundT 1)
+ (#BoundT 0)
(#Cons ## "lux;AliasD"
Ident
#Nil))))))))
@@ -337,7 +337,7 @@
(#Cons ## "lux;defs"
(#AppT List (#TupleT (#Cons Text
(#Cons (#TupleT (#Cons Bool (#Cons (#AppT DefData' (#LambdaT ASTList
- (#AppT (#AppT StateE (#BoundT 1))
+ (#AppT (#AppT StateE (#BoundT 0))
ASTList)))
#Nil)))
#Nil))))
@@ -382,7 +382,7 @@
Cursor
(#Cons ## "lux;modules"
(#AppT List (#TupleT (#Cons Text
- (#Cons (#AppT Module (#AppT (#BoundT 0) (#BoundT 1)))
+ (#Cons (#AppT Module (#AppT (#BoundT 1) (#BoundT 0)))
#Nil))))
(#Cons ## "lux;envs"
(#AppT List (#AppT (#AppT Env Text)
@@ -441,11 +441,11 @@
## ...)
(_lux_def return
(_lux_: (#UnivQ #Nil
- (#LambdaT (#BoundT 1)
+ (#LambdaT (#BoundT 0)
(#LambdaT Compiler
(#AppT (#AppT Either Text)
(#TupleT (#Cons Compiler
- (#Cons (#BoundT 1)
+ (#Cons (#BoundT 0)
#Nil)))))))
(_lux_lambda _ val
(_lux_lambda _ state
@@ -462,7 +462,7 @@
(#LambdaT Compiler
(#AppT (#AppT Either Text)
(#TupleT (#Cons Compiler
- (#Cons (#BoundT 1)
+ (#Cons (#BoundT 0)
#Nil)))))))
(_lux_lambda _ msg
(_lux_lambda _ state
@@ -678,9 +678,9 @@
(def'' (map f xs)
(#UnivQ #Nil
(#UnivQ #Nil
- (#LambdaT (#LambdaT (#BoundT 3) (#BoundT 1))
- (#LambdaT ($' List (#BoundT 3))
- ($' List (#BoundT 1))))))
+ (#LambdaT (#LambdaT (#BoundT 2) (#BoundT 0))
+ (#LambdaT ($' List (#BoundT 2))
+ ($' List (#BoundT 0))))))
(_lux_case xs
#Nil
#Nil
@@ -793,8 +793,8 @@
(def'' (parse-univq-args args next)
## (All [a] (-> (List AST) (-> (List Text) (Lux a)) (Lux a)))
(#UnivQ #Nil (#LambdaT ($' List AST)
- (#LambdaT (#LambdaT ($' List Text) (#AppT (#AppT StateE Compiler) (#BoundT 1)))
- (#AppT (#AppT StateE Compiler) (#BoundT 1)))))
+ (#LambdaT (#LambdaT ($' List Text) (#AppT (#AppT StateE Compiler) (#BoundT 0)))
+ (#AppT (#AppT StateE Compiler) (#BoundT 0)))))
(_lux_case args
#Nil
(next #Nil)
@@ -811,12 +811,12 @@
(def'' (foldL f init xs)
## (All [a b] (-> (-> a b a) a (List b) a))
- (#UnivQ #Nil (#UnivQ #Nil (#LambdaT (#LambdaT (#BoundT 3)
- (#LambdaT (#BoundT 1)
- (#BoundT 3)))
- (#LambdaT (#BoundT 3)
- (#LambdaT ($' List (#BoundT 1))
- (#BoundT 3))))))
+ (#UnivQ #Nil (#UnivQ #Nil (#LambdaT (#LambdaT (#BoundT 2)
+ (#LambdaT (#BoundT 0)
+ (#BoundT 2)))
+ (#LambdaT (#BoundT 2)
+ (#LambdaT ($' List (#BoundT 0))
+ (#BoundT 2))))))
(_lux_case xs
#Nil
init
@@ -839,9 +839,9 @@
(lambda'' [body' name']
(form$ (#Cons (tag$ ["lux" "UnivQ"])
(#Cons (tag$ ["lux" "Nil"])
- (#Cons (replace-syntax (#Cons [name' (make-bound 1)] #Nil)
+ (#Cons (replace-syntax (#Cons [name' (make-bound 0)] #Nil)
(update-bounds body')) #Nil))))))
- (replace-syntax (#Cons [self-name (make-bound -2)] #Nil)
+ (replace-syntax (#Cons [self-name (make-bound -1)] #Nil)
body)
names)
(return (#Cons body' #Nil)))))
@@ -865,9 +865,9 @@
(lambda'' [body' name']
(form$ (#Cons (tag$ ["lux" "ExQ"])
(#Cons (tag$ ["lux" "Nil"])
- (#Cons (replace-syntax (#Cons [name' (make-bound 1)] #Nil)
+ (#Cons (replace-syntax (#Cons [name' (make-bound 0)] #Nil)
(update-bounds body')) #Nil))))))
- (replace-syntax (#Cons [self-name (make-bound -2)] #Nil)
+ (replace-syntax (#Cons [self-name (make-bound -1)] #Nil)
body)
names)
(return (#Cons body' #Nil)))))
@@ -1799,7 +1799,7 @@
(defmacro' #export (Rec tokens)
(_lux_case tokens
(#Cons [_ (#SymbolS "" name)] (#Cons body #Nil))
- (let' [body' (replace-syntax (@list [name (` (#AppT (~ (make-bound 0)) (~ (make-bound 1))))]) body)]
+ (let' [body' (replace-syntax (@list [name (` (#AppT (~ (make-bound 1)) (~ (make-bound 0))))]) body)]
(return (@list (` (#AppT (#UnivQ #Nil (~ body')) Void)))))
_
@@ -2300,7 +2300,7 @@
(-> Type Type (Maybe Type))
(case type-fn
(#UnivQ env body)
- (#Some (beta-reduce (@list& type-fn param env) body))
+ (#Some (beta-reduce (@list& param type-fn env) body))
(#AppT F A)
(do Maybe/Monad
diff --git a/src/lux/analyser/case.clj b/src/lux/analyser/case.clj
index 109ba7c41..c6806a627 100644
--- a/src/lux/analyser/case.clj
+++ b/src/lux/analyser/case.clj
@@ -68,7 +68,7 @@
(&type/with-var
(fn [$var]
(|do [=type (&type/apply-type type $var)]
- (adjust-type* (&/Cons$ (&/T _aenv 1 $var) (&/|map update-up-frame up)) =type))))
+ (adjust-type* (&/Cons$ (&/T _aenv 0 $var) (&/|map update-up-frame up)) =type))))
(&/$TupleT ?members)
(|do [(&/$TupleT ?members*) (&/fold% (fn [_abody ena]
diff --git a/src/lux/analyser/host.clj b/src/lux/analyser/host.clj
index 681f22168..f17be2a7c 100644
--- a/src/lux/analyser/host.clj
+++ b/src/lux/analyser/host.clj
@@ -265,9 +265,10 @@
(defn analyse-jvm-new [analyse exo-type class classes args]
(|do [class-loader &/loader
- =return (&host/lookup-constructor class-loader class classes)
+ [=return exceptions] (&host/lookup-constructor class-loader class classes)
=args (&/map2% (fn [c o] (&&/analyse-1 analyse (&type/Data$ c &/Nil$) o))
classes args)
+ _ (ensure-catching exceptions)
:let [output-type (&type/Data$ class &/Nil$)]
_ (&type/check exo-type output-type)]
(return (&/|list (&/T (&/V &&/$jvm-new (&/T class classes =args)) output-type)))))
diff --git a/src/lux/host.clj b/src/lux/host.clj
index eafd6a1ac..6be162bf7 100644
--- a/src/lux/host.clj
+++ b/src/lux/host.clj
@@ -176,7 +176,7 @@
args
(&/|map #(.getName ^Class %) param-types))))]
=method))]
- (return &type/Unit)
+ (return (&/T &type/Unit (->> ctor .getExceptionTypes &/->list (&/|map #(.getName %)))))
(fail (str "[Host Error] Constructor does not exist: " target))))
(defn abstract-methods [class-loader class]
diff --git a/src/lux/type.clj b/src/lux/type.clj
index baf834ee6..d6275651e 100644
--- a/src/lux/type.clj
+++ b/src/lux/type.clj
@@ -58,7 +58,7 @@
(def IO
(Named$ (&/T "lux/data" "IO")
(Univ$ empty-env
- (Lambda$ Unit (Bound$ 1)))))
+ (Lambda$ Unit (Bound$ 0)))))
(def List
(Named$ (&/T "lux" "List")
@@ -67,9 +67,9 @@
;; lux;Nil
Unit
;; lux;Cons
- (Tuple$ (&/|list (Bound$ 1)
- (App$ (Bound$ 0)
- (Bound$ 1))))
+ (Tuple$ (&/|list (Bound$ 0)
+ (App$ (Bound$ 1)
+ (Bound$ 0))))
)))))
(def Maybe
@@ -79,12 +79,12 @@
;; lux;None
Unit
;; lux;Some
- (Bound$ 1)
+ (Bound$ 0)
)))))
(def Type
(Named$ (&/T "lux" "Type")
- (let [Type (App$ (Bound$ 0) (Bound$ 1))
+ (let [Type (App$ (Bound$ 1) (Bound$ 0))
TypeList (App$ List Type)
TypePair (Tuple$ (&/|list Type Type))]
(App$ (Univ$ empty-env
@@ -123,13 +123,13 @@
Int
;; "lux;mappings"
(App$ List
- (Tuple$ (&/|list (Bound$ 3)
- (Bound$ 1))))))))))
+ (Tuple$ (&/|list (Bound$ 2)
+ (Bound$ 0))))))))))
(def Env
(Named$ (&/T "lux" "Env")
- (let [bindings (App$ (App$ Bindings (Bound$ 3))
- (Bound$ 1))]
+ (let [bindings (App$ (App$ Bindings (Bound$ 2))
+ (Bound$ 0))]
(Univ$ empty-env
(Univ$ empty-env
(Tuple$
@@ -152,14 +152,14 @@
(Named$ (&/T "lux" "Meta")
(Univ$ empty-env
(Univ$ empty-env
- (Tuple$ (&/|list (Bound$ 3)
- (Bound$ 1)))))))
+ (Tuple$ (&/|list (Bound$ 2)
+ (Bound$ 0)))))))
(def AST*
(Named$ (&/T "lux" "AST'")
- (let [AST* (App$ (Bound$ 1)
- (App$ (Bound$ 0)
- (Bound$ 1)))
+ (let [AST* (App$ (Bound$ 0)
+ (App$ (Bound$ 1)
+ (Bound$ 0)))
AST*List (App$ List AST*)]
(Univ$ empty-env
(Variant$ (&/|list
@@ -198,17 +198,17 @@
(Univ$ empty-env
(Variant$ (&/|list
;; &/$Left
- (Bound$ 3)
+ (Bound$ 2)
;; &/$Right
- (Bound$ 1)))))))
+ (Bound$ 0)))))))
(def StateE
(Univ$ empty-env
(Univ$ empty-env
- (Lambda$ (Bound$ 3)
+ (Lambda$ (Bound$ 2)
(App$ (App$ Either Text)
- (Tuple$ (&/|list (Bound$ 3)
- (Bound$ 1))))))))
+ (Tuple$ (&/|list (Bound$ 2)
+ (Bound$ 0))))))))
(def Source
(Named$ (&/T "lux" "Source")
@@ -238,7 +238,7 @@
;; "lux;TypeD"
Type
;; "lux;MacroD"
- (Bound$ 1)
+ (Bound$ 0)
;; "lux;AliasD"
Ident
))))
@@ -263,7 +263,7 @@
(Tuple$ (&/|list Bool
(App$ DefData*
(Lambda$ ASTList
- (App$ (App$ StateE (Bound$ 1))
+ (App$ (App$ StateE (Bound$ 0))
ASTList))))))))
;; "lux;imports"
(App$ List Text)
@@ -293,7 +293,7 @@
Cursor
;; "lux;modules"
(App$ List (Tuple$ (&/|list Text
- (App$ $Module (App$ (Bound$ 0) (Bound$ 1))))))
+ (App$ $Module (App$ (Bound$ 1) (Bound$ 0))))))
;; "lux;envs"
(App$ List
(App$ (App$ Env Text)
@@ -645,8 +645,8 @@
(|case type-fn
(&/$UnivQ local-env local-def)
(return (beta-reduce (->> local-env
- (&/Cons$ param)
- (&/Cons$ type-fn))
+ (&/Cons$ type-fn)
+ (&/Cons$ param))
local-def))
(&/$AppT F A)