From 530a14bfe7714f94babdb34c237b88321408a685 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 13 Nov 2017 23:45:12 -0400 Subject: - More refactoring. --- new-luxc/source/luxc/lang/analysis/inference.lux | 50 ++++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'new-luxc/source/luxc/lang/analysis/inference.lux') diff --git a/new-luxc/source/luxc/lang/analysis/inference.lux b/new-luxc/source/luxc/lang/analysis/inference.lux index 934ecafa5..5152de0b6 100644 --- a/new-luxc/source/luxc/lang/analysis/inference.lux +++ b/new-luxc/source/luxc/lang/analysis/inference.lux @@ -6,7 +6,7 @@ [text] text/format (coll [list "list/" Functor])) - [meta #+ Monad] + [meta "meta/" Monad] (meta [type] (type ["tc" check]))) (luxc ["&" base] @@ -95,23 +95,23 @@ ## tagged variants). ## But, so long as the type being used for the inference can be treated ## as a function type, this method of inference should work. -(def: #export (apply-function analyse inferT args) +(def: #export (general analyse inferT args) (-> &;Analyser Type (List Code) (Meta [Type (List Analysis)])) (case args #;Nil - (do Monad + (do meta;Monad [_ (&;infer inferT)] (wrap [inferT (list)])) (#;Cons argC args') (case inferT (#;Named name unnamedT) - (apply-function analyse unnamedT args) + (general analyse unnamedT args) (#;UnivQ _) - (do Monad + (do meta;Monad [[var-id varT] (&;with-type-env tc;var) - [outputT argsA] (apply-function analyse (maybe;assume (type;apply (list varT) inferT)) args)] + [outputT argsA] (general analyse (maybe;assume (type;apply (list varT) inferT)) args)] (do @ [? (&;with-type-env (tc;concrete? var-id)) @@ -124,15 +124,15 @@ (wrap [outputT' argsA]))) (#;ExQ _) - (do Monad + (do meta;Monad [[ex-id exT] (&;with-type-env tc;existential)] - (apply-function analyse (maybe;assume (type;apply (list exT) inferT)) args)) + (general analyse (maybe;assume (type;apply (list exT) inferT)) args)) (#;Apply inputT transT) (case (type;apply (list inputT) transT) (#;Some outputT) - (apply-function analyse outputT args) + (general analyse outputT args) #;None (&;throw Invalid-Type-Application (%type inferT))) @@ -145,8 +145,8 @@ ## avoided in Lux code, since the inference algorithm can piece ## things together more easily. (#;Function inputT outputT) - (do Monad - [[outputT' args'A] (apply-function analyse outputT args') + (do meta;Monad + [[outputT' args'A] (general analyse outputT args') argA (&;with-stacked-errors (function [_] (Cannot-Infer-Argument (format "Inferred Type: " (%type inputT) "\n" @@ -174,14 +174,14 @@ (^template [] ( env bodyT) - (do Monad + (do meta;Monad [bodyT+ (record bodyT)] (wrap ( env bodyT+)))) ([#;UnivQ] [#;ExQ]) (#;Product _) - (:: Monad wrap (type;function (type;flatten-tuple type) type)) + (meta/wrap (type;function (type;flatten-tuple type) type)) _ (&;throw Not-A-Record-Type (%type type)))) @@ -193,13 +193,13 @@ currentT type] (case currentT (#;Named name unnamedT) - (do Monad + (do meta;Monad [unnamedT+ (recur depth unnamedT)] (wrap unnamedT+)) (^template [] ( env bodyT) - (do Monad + (do meta;Monad [bodyT+ (recur (n.inc depth) bodyT)] (wrap ( env bodyT+)))) ([#;UnivQ] @@ -214,11 +214,11 @@ (n.< boundary tag))) (case (list;nth tag cases) (#;Some caseT) - (:: Monad wrap (if (n.= +0 depth) - (type;function (list caseT) currentT) - (let [replace! (replace-bound (|> depth n.dec (n.* +2)) type)] - (type;function (list (replace! caseT)) - (replace! currentT))))) + (meta/wrap (if (n.= +0 depth) + (type;function (list caseT) currentT) + (let [replace! (replace-bound (|> depth n.dec (n.* +2)) type)] + (type;function (list (replace! caseT)) + (replace! currentT))))) #;None (&common;variant-out-of-bounds-error type expected-size tag)) @@ -230,11 +230,11 @@ (n.= boundary tag) (let [caseT (type;variant (list;drop boundary cases))] - (:: Monad wrap (if (n.= +0 depth) - (type;function (list caseT) currentT) - (let [replace! (replace-bound (|> depth n.dec (n.* +2)) type)] - (type;function (list (replace! caseT)) - (replace! currentT)))))) + (meta/wrap (if (n.= +0 depth) + (type;function (list caseT) currentT) + (let [replace! (replace-bound (|> depth n.dec (n.* +2)) type)] + (type;function (list (replace! caseT)) + (replace! currentT)))))) ## else (&common;variant-out-of-bounds-error type expected-size tag))) -- cgit v1.2.3