aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
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)