aboutsummaryrefslogtreecommitdiff
path: root/src/lux/analyser/base.clj
diff options
context:
space:
mode:
authorEduardo Julian2015-04-16 15:37:27 -0400
committerEduardo Julian2015-04-16 15:37:27 -0400
commit12aed842461ecc596c07227dcefce36d440e2c85 (patch)
treeee4275cf2ffd89192f91414134cd38982003fb4a /src/lux/analyser/base.clj
parentf6dc520d04b517cd8e907d4738aae60b279c3877 (diff)
- Type-vars can now be deleted and be scoped (through with-var).
- Fixed a few bugs with types and pattern-matching. - Fixed a bug wherein primitive-analysis did now unify the primitive type with the exotype. - Modified lambda-analysis so functions subject to universal quantification can manage better the universally-quantified variables.
Diffstat (limited to 'src/lux/analyser/base.clj')
-rw-r--r--src/lux/analyser/base.clj18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lux/analyser/base.clj b/src/lux/analyser/base.clj
index 0d2d8304a..35c12c3e0 100644
--- a/src/lux/analyser/base.clj
+++ b/src/lux/analyser/base.clj
@@ -37,9 +37,21 @@
(fail "[Analyser Error] Can't expand to other than 2 elements.")))))
(defn with-var [k]
- (|do [=var &type/fresh-var
+ (|do [=var &type/create-var
=ret (k =var)]
(matchv ::M/objects [=ret]
[["Expression" [?expr ?type]]]
- (|do [=type (&type/clean =var ?type)]
- (return (&/V "Expression" (&/T ?expr =type)))))))
+ (|do [id (&type/var-id =var)
+ =type (&type/clean id ?type)
+ :let [_ (prn 'with-var/CLEANING id)]
+ _ (&type/delete-var id)]
+ (return (&/V "Expression" (&/T ?expr =type))))
+
+ [_]
+ (assert false (pr-str '&&/with-var (aget =ret 0))))))
+
+(defmacro with-vars [vars body]
+ (reduce (fn [b v]
+ `(with-var (fn [~v] ~b)))
+ body
+ (reverse vars)))