aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux.lux')
-rw-r--r--stdlib/source/library/lux.lux62
1 files changed, 53 insertions, 9 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 84f0ddf14..df7b4ef66 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -4298,6 +4298,56 @@
bound
(type_variable idx bindings'))))
+(def (clean_type variables it)
+ (-> (List [Nat (Maybe Type)]) Type Type)
+ (when it
+ {#Primitive name parameters}
+ {#Primitive name (list#each (clean_type variables) parameters)}
+
+ {#Sum left right}
+ {#Sum (clean_type variables left)
+ (clean_type variables right)}
+
+ {#Product left right}
+ {#Product (clean_type variables left)
+ (clean_type variables right)}
+
+ {#Function left right}
+ {#Function (clean_type variables left)
+ (clean_type variables right)}
+
+ {#Apply left right}
+ {#Apply (clean_type variables left)
+ (clean_type variables right)}
+
+ {#UnivQ environment unquantified}
+ {#UnivQ (list#each (clean_type variables) environment)
+ (clean_type variables unquantified)}
+
+ {#ExQ environment unquantified}
+ {#ExQ (list#each (clean_type variables) environment)
+ (clean_type variables unquantified)}
+
+ {#Named name anonymous}
+ it
+
+ {#Parameter _}
+ it
+
+ {#Ex _}
+ it
+
+ {#Var id}
+ (when (type_variable id variables)
+ {#None}
+ it
+
+ {#Some {#Var _}}
+ it
+
+ {#Some it}
+ (clean_type variables it))))
+
(def (type_definition full_name)
(-> Symbol (Meta Type))
(do meta#monad
@@ -4324,22 +4374,16 @@
_
{#Left (all text#composite "Unknown var: " (symbol#encoded full_name))})))]
(when temp
- {#Right [compiler {#Var type_id}]}
+ {#Right [compiler temp]}
(let [[..#info _ ..#source _ ..#current_module _ ..#modules _
..#scopes _ ..#type_context type_context ..#host _
..#seed _ ..#expected _ ..#location _ ..#extensions extensions
..#scope_type_vars _ ..#eval _eval] compiler
[..#ex_counter _ ..#var_counter _ ..#var_bindings var_bindings] type_context]
- (when (type_variable type_id var_bindings)
- {#None}
- temp
-
- {#Some actualT}
- {#Right [compiler actualT]}))
+ {#Right [compiler (clean_type var_bindings temp)]})
_
- temp))
- )))
+ temp)))))
(def (list#all choice items)
(All (_ a b) (-> (-> a (Maybe b)) (List a) (List b)))