From 60e45bab087d2598510189cbec29b4a566671273 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 15 Feb 2016 13:03:21 -0400 Subject: - Improved the instantiation of generic types when using unparameterized classes. - Added beta-reduction for ExQ. - Improved ident->text. --- src/lux/base.clj | 4 +++- src/lux/type.clj | 18 +++++++++++------- src/lux/type/host.clj | 4 +++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/lux/base.clj b/src/lux/base.clj index d653a11b1..74bb7bfc1 100644 --- a/src/lux/base.clj +++ b/src/lux/base.clj @@ -934,7 +934,9 @@ (defn ident->text [ident] (|let [[?module ?name] ident] - (str ?module ";" ?name))) + (if (= "" ?module) + ?name + (str ?module ";" ?name)))) (defn fold2% [f init xs ys] (|case [xs ys] diff --git a/src/lux/type.clj b/src/lux/type.clj index 8869b2577..224308f0f 100644 --- a/src/lux/type.clj +++ b/src/lux/type.clj @@ -514,18 +514,14 @@ (&/$DataT ?name (&/|map (partial beta-reduce env) ?params)) (&/$SumT ?left ?right) - (let [=left (beta-reduce env ?left) - =right (beta-reduce env ?right)] - (&/$SumT =left =right)) + (&/$SumT (beta-reduce env ?left) (beta-reduce env ?right)) (&/$ProdT ?left ?right) - (let [=left (beta-reduce env ?left) - =right (beta-reduce env ?right)] - (&/$ProdT =left =right)) + (&/$ProdT (beta-reduce env ?left) (beta-reduce env ?right)) (&/$AppT ?type-fn ?type-arg) (&/$AppT (beta-reduce env ?type-fn) (beta-reduce env ?type-arg)) - + (&/$UnivQ ?local-env ?local-def) (|case ?local-env (&/$Nil) @@ -534,6 +530,14 @@ _ type) + (&/$ExQ ?local-env ?local-def) + (|case ?local-env + (&/$Nil) + (&/$ExQ env ?local-def) + + _ + type) + (&/$LambdaT ?input ?output) (&/$LambdaT (beta-reduce env ?input) (beta-reduce env ?output)) diff --git a/src/lux/type/host.clj b/src/lux/type/host.clj index 1a174bb27..9717b0e75 100644 --- a/src/lux/type/host.clj +++ b/src/lux/type/host.clj @@ -81,7 +81,9 @@ (if (.equals "void" base) &/$UnitT (reduce (fn [inner _] (&/$DataT array-data-tag (&/|list inner))) - (&/$DataT base &/$Nil) + (&/$DataT base (-> class .getTypeParameters + seq count (repeat (&/$DataT "java.lang.Object" &/$Nil)) + &/->list)) (range (count (or arr-obrackets arr-pbrackets ""))))) )))) -- cgit v1.2.3