aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Julian2015-05-01 21:58:55 -0400
committerEduardo Julian2015-05-01 21:58:55 -0400
commit6bb629a6917176ec46fee119b3b21fb1781cba78 (patch)
tree24cbff805c7489d1d6bbae6c80ed3cf8da0bc460 /src
parent52d428514631cf9ed54e2f8ad418ea21165011c7 (diff)
- Added existential types via #ExT.
- Removed the (now useless) lux.type/is-Type? function.
Diffstat (limited to 'src')
-rw-r--r--src/lux.clj10
-rw-r--r--src/lux/analyser/lux.clj18
-rw-r--r--src/lux/type.clj36
3 files changed, 18 insertions, 46 deletions
diff --git a/src/lux.clj b/src/lux.clj
index 83353f7e9..b69494909 100644
--- a/src/lux.clj
+++ b/src/lux.clj
@@ -4,15 +4,7 @@
:reload-all))
(comment
- ;; TODO: Finish type system.
- ;; TODO: Re-implement compiler in language.
- ;; TODO: Add source-file information to .class files for easier debugging.
- ;; TODO: Finish implementing class & interface definition
- ;; TODO: All optimizations
- ;; TODO: Anonymous classes
- ;; TODO:
-
- ;; Finish total-locals
+ ;; TODO: Finish total-locals
(time (&compiler/compile-all (&/|list "lux")))
(System/gc)
diff --git a/src/lux/analyser/lux.clj b/src/lux/analyser/lux.clj
index b868312d3..fc99fa50f 100644
--- a/src/lux/analyser/lux.clj
+++ b/src/lux/analyser/lux.clj
@@ -310,29 +310,19 @@
(&type/with-var
(fn [$var]
(|do [exo-type* (&type/apply-type exo-type $var)
- output (analyse-lambda** analyse exo-type* ?self ?arg ?body)]
+ [_expr _] (analyse-lambda** analyse exo-type* ?self ?arg ?body)]
(matchv ::M/objects [$var]
[["lux;VarT" ?id]]
(|do [? (&type/bound? ?id)]
(if ?
(|do [dtype (&type/deref ?id)]
(matchv ::M/objects [dtype]
- [["lux;BoundT" _]]
- (matchv ::M/objects [output]
- [[_expr _]]
- ;; (|do [_ (&type/set-var ?id (&/V "lux;BoundT" _arg))]
- ;; (return (&/T _expr exo-type)))
- (return (&/T _expr exo-type))
- )
+ [["lux;ExT" _]]
+ (return (&/T _expr exo-type))
[_]
(fail (str "[Analyser Error] Can't use type-var in any type-specific way inside polymorphic functions: " ?id ":" _arg " " (&type/show-type dtype)))))
- (matchv ::M/objects [output]
- [[_expr _]]
- ;; (|do [_ (&type/set-var ?id (&/V "lux;BoundT" _arg))]
- ;; (return (&/T _expr exo-type)))
- (return (&/T _expr exo-type))
- )))))))
+ (return (&/T _expr exo-type))))))))
[_]
(|do [exo-type* (&type/actual-type exo-type)]
diff --git a/src/lux/type.clj b/src/lux/type.clj
index b739be3c2..ce16cec3d 100644
--- a/src/lux/type.clj
+++ b/src/lux/type.clj
@@ -41,6 +41,7 @@
(&/T "lux;VarT" Int)
(&/T "lux;AllT" (&/V "lux;TupleT" (&/|list (&/V "lux;AppT" (&/T Maybe TypeEnv)) Text Text Type)))
(&/T "lux;AppT" TypePair)
+ (&/T "lux;ExT" Int)
))))
$Void))))
@@ -217,7 +218,7 @@
_ (if ?
(return nil)
(|do [seed &/gen-id]
- (set-var id (&/V "lux;BoundT" (str seed)))))]
+ (set-var id (&/V "lux;ExT" seed))))]
(fn [state]
(&/run-state (|do [mappings* (&/map% (fn [binding]
(|let [[?id ?type] binding]
@@ -368,6 +369,9 @@
[["lux;BoundT" name]]
name
+ [["lux;ExT" ?id]]
+ (str "⟨" ?id "⟩")
+
[["lux;AppT" [?lambda ?param]]]
(str "(" (show-type ?lambda) " " (show-type ?param) ")")
@@ -426,6 +430,9 @@
[["lux;BoundT" xname] ["lux;BoundT" yname]]
(= xname yname)
+ [["lux;ExT" xid] ["lux;ExT" yid]]
+ (= xid yid)
+
[["lux;AppT" [xlambda xparam]] ["lux;AppT" [ylambda yparam]]]
(and (type= xlambda ylambda)
(type= xparam yparam))
@@ -576,9 +583,11 @@
(return (&/V "lux;None" nil))))]
(matchv ::M/objects [ebound abound]
[["lux;None" _] ["lux;None" _]]
+ ;; (|do [_ (set-var ?aid expected)]
+ ;; (return (&/T fixpoints nil)))
(|do [_ (set-var ?eid actual)]
(return (&/T fixpoints nil)))
-
+
[["lux;Some" etype] ["lux;None" _]]
(check* fixpoints etype actual)
;; (|do [_ (set-var ?aid etype)]
@@ -755,8 +764,8 @@
(return (&/T fixpoints* nil)))
(fail "[Type Error] Records don't match in size."))
- [["lux;BoundT" e!name] ["lux;BoundT" a!name]]
- (if (= e!name a!name)
+ [["lux;ExT" e!id] ["lux;ExT" a!id]]
+ (if (= e!id a!id)
(return (&/T fixpoints nil))
(check-error expected actual))
@@ -811,22 +820,3 @@
[_]
(fail (str "[Type Error] Type is not a variant: " (show-type type)))))
-
-(let [type-cases #{"lux;DataT" , "lux;LambdaT" , "lux;AppT"
- "lux;TupleT", "lux;VariantT", "lux;RecordT"
- "lux;AllT" , "lux;VarT" , "lux;BoundT"}]
- (defn is-Type? [type]
- (matchv ::M/objects [type]
- [["lux;VarT" ?id]]
- (&/try-all% (&/|list (|do [type* (deref ?id)]
- (is-Type? type*))
- (return false)))
-
- [_]
- (|do [type* (actual-type type)]
- (matchv ::M/objects [type*]
- [["lux;VariantT" ?cases]]
- (return (->> ?cases &/|keys &/->seq set (= type-cases)))
-
- [_]
- (return false))))))