From b08f7d83a591be770af64b4c9ccd59f3306689e8 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 13 Nov 2017 21:13:00 -0400 Subject: - Improved handling of type variables. --- .../source/luxc/lang/analysis/procedure/common.lux | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'new-luxc/source/luxc/lang/analysis/procedure/common.lux') diff --git a/new-luxc/source/luxc/lang/analysis/procedure/common.lux b/new-luxc/source/luxc/lang/analysis/procedure/common.lux index c8e3e3b38..778e57b94 100644 --- a/new-luxc/source/luxc/lang/analysis/procedure/common.lux +++ b/new-luxc/source/luxc/lang/analysis/procedure/common.lux @@ -151,6 +151,42 @@ [lux//check typeA;analyse-check] [lux//coerce typeA;analyse-coerce]) +(def: (clean-type inputT) + (-> Type (tc;Check Type)) + (case inputT + (#;Primitive name paramsT+) + (do tc;Monad + [paramsT+' (monad;map @ clean-type paramsT+)] + (wrap (#;Primitive name paramsT+'))) + + (^or #;Void #;Unit (#;Bound _) (#;Ex _) (#;Named _)) + (:: tc;Monad wrap inputT) + + (^template [] + ( leftT rightT) + (do tc;Monad + [leftT' (clean-type leftT) + rightT' (clean-type rightT)] + (wrap ( leftT' rightT')))) + ([#;Sum] [#;Product] [#;Function] [#;Apply]) + + (#;Var id) + (do tc;Monad + [? (tc;concrete? id)] + (if ? + (do @ + [actualT (tc;read id)] + (clean-type actualT)) + (wrap inputT))) + + (^template [] + ( envT+ unquantifiedT) + (do tc;Monad + [envT+' (monad;map @ clean-type envT+)] + (wrap ( envT+' unquantifiedT)))) + ([#;UnivQ] [#;ExQ]) + )) + (def: (lux//check//type proc) (-> Text Proc) (function [analyse eval args] -- cgit v1.2.3