aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2017-11-15 20:35:56 -0400
committerEduardo Julian2017-11-15 20:35:56 -0400
commit094c0904470f85ff0d63c788e07ce1ecf355577e (patch)
treea55c642d0ae834e79ddd8549ff2bc5c4c39e4b30 /stdlib/source
parentaf1417bf28529a8fec06901d586b60b41bba8f76 (diff)
- Moved type-cleaning to lux/meta/type/check.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/meta/type/check.lux38
1 files changed, 37 insertions, 1 deletions
diff --git a/stdlib/source/lux/meta/type/check.lux b/stdlib/source/lux/meta/type/check.lux
index 74c5a2a90..91e8f3bdf 100644
--- a/stdlib/source/lux/meta/type/check.lux
+++ b/stdlib/source/lux/meta/type/check.lux
@@ -17,7 +17,6 @@
(exception: #export Unknown-Type-Var)
(exception: #export Unbound-Type-Var)
(exception: #export Improper-Ring)
-(exception: #export Cannot-Clean-Unbound-Var)
(exception: #export Invalid-Type-Application)
(exception: #export Cannot-Rebind-Var)
(exception: #export Type-Check-Failed)
@@ -628,3 +627,40 @@
(Check Type-Context)
(function [context]
(#e;Success [context context])))
+
+(def: #export (clean inputT)
+ (-> Type (Check Type))
+ (case inputT
+ (#;Primitive name paramsT+)
+ (do Monad<Check>
+ [paramsT+' (monad;map @ clean paramsT+)]
+ (wrap (#;Primitive name paramsT+')))
+
+ (^or #;Void #;Unit (#;Bound _) (#;Ex _) (#;Named _))
+ (:: Monad<Check> wrap inputT)
+
+ (^template [<tag>]
+ (<tag> leftT rightT)
+ (do Monad<Check>
+ [leftT' (clean leftT)
+ rightT' (clean rightT)]
+ (wrap (<tag> leftT' rightT'))))
+ ([#;Sum] [#;Product] [#;Function] [#;Apply])
+
+ (#;Var id)
+ (do Monad<Check>
+ [?actualT (read id)]
+ (case ?actualT
+ (#;Some actualT)
+ (clean actualT)
+
+ _
+ (wrap inputT)))
+
+ (^template [<tag>]
+ (<tag> envT+ unquantifiedT)
+ (do Monad<Check>
+ [envT+' (monad;map @ clean envT+)]
+ (wrap (<tag> envT+' unquantifiedT))))
+ ([#;UnivQ] [#;ExQ])
+ ))