aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2017-11-14 20:03:14 -0400
committerEduardo Julian2017-11-14 20:03:14 -0400
commitb88027c19181f24584d5ad1c46fb2443d65edece (patch)
treeae6ce4b8cc4dab3a5b05e9e9759df041509c4113 /stdlib/source
parent686a46f569b818681583e6ce75b37b25642b375b (diff)
- Fixed some bugs.
- new-luxc can now fully compile lux.lux!
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux57
1 files changed, 42 insertions, 15 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 70563181a..0da0a628a 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -4281,30 +4281,57 @@
(#Some [def-type def-meta def-value])
(#Right [state [def-type def-value]])))))
+(def: (find-type-var idx bindings)
+ (-> Nat (List [Nat (Maybe Type)]) (Maybe Type))
+ (case bindings
+ #;Nil
+ #;Nil
+
+ (#;Cons [var bound] bindings')
+ (if (n.= idx var)
+ bound
+ (find-type-var idx bindings'))))
+
(def: (find-type ident)
(-> Ident (Meta Type))
(do Monad<Meta>
[#let [[module name] ident]
current-module current-module-name]
- (function [state]
- (if (text/= "" module)
- (case (find-in-env name state)
- (#Some struct-type)
- (#Right state struct-type)
+ (function [compiler]
+ (let [temp (if (text/= "" module)
+ (case (find-in-env name compiler)
+ (#Some struct-type)
+ (#Right [compiler struct-type])
- _
- (case (find-def-type [current-module name] state)
- (#Some struct-type)
- (#Right state struct-type)
+ _
+ (case (find-def-type [current-module name] compiler)
+ (#Some struct-type)
+ (#Right [compiler struct-type])
- _
- (#Left ($_ text/compose "Unknown var: " (ident/encode ident)))))
- (case (find-def-type ident state)
- (#Some struct-type)
- (#Right state struct-type)
+ _
+ (#Left ($_ text/compose "Unknown var: " (ident/encode ident)))))
+ (case (find-def-type ident compiler)
+ (#Some struct-type)
+ (#Right [compiler struct-type])
+
+ _
+ (#Left ($_ text/compose "Unknown var: " (ident/encode ident)))))]
+ (case temp
+ (#Right [compiler (#Var type-id)])
+ (let [{#info _ #source _ #current-module _ #modules _
+ #scopes _ #type-context type-context #host _
+ #seed _ #expected _ #cursor _
+ #scope-type-vars _} compiler
+ {#ex-counter _ #var-counter _ #var-bindings var-bindings} type-context]
+ (case (find-type-var type-id var-bindings)
+ #;None
+ temp
+
+ (#;Some actualT)
+ (#Right [compiler actualT])))
_
- (#Left ($_ text/compose "Unknown var: " (ident/encode ident)))))
+ temp))
)))
(def: (zip2 xs ys)