diff options
author | Eduardo Julian | 2017-11-13 23:45:12 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-13 23:45:12 -0400 |
commit | 530a14bfe7714f94babdb34c237b88321408a685 (patch) | |
tree | e91f3059694f707a8b70c4b4adac2e3b6ec1553b /new-luxc/source/luxc/lang/analysis/inference.lux | |
parent | 70005a6dee1eba3e3f5694aa4903e95988dcaa3d (diff) |
- More refactoring.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/inference.lux | 50 |
1 files changed, 25 insertions, 25 deletions
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<List>])) - [meta #+ Monad<Meta>] + [meta "meta/" Monad<Meta>] (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<Meta> + (do meta;Monad<Meta> [_ (&;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<Meta> + (do meta;Monad<Meta> [[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<Meta> + (do meta;Monad<Meta> [[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<Meta> - [[outputT' args'A] (apply-function analyse outputT args') + (do meta;Monad<Meta> + [[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 [<tag>] (<tag> env bodyT) - (do Monad<Meta> + (do meta;Monad<Meta> [bodyT+ (record bodyT)] (wrap (<tag> env bodyT+)))) ([#;UnivQ] [#;ExQ]) (#;Product _) - (:: Monad<Meta> 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<Meta> + (do meta;Monad<Meta> [unnamedT+ (recur depth unnamedT)] (wrap unnamedT+)) (^template [<tag>] (<tag> env bodyT) - (do Monad<Meta> + (do meta;Monad<Meta> [bodyT+ (recur (n.inc depth) bodyT)] (wrap (<tag> env bodyT+)))) ([#;UnivQ] @@ -214,11 +214,11 @@ (n.< boundary tag))) (case (list;nth tag cases) (#;Some caseT) - (:: Monad<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))))) + (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<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)))))) + (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))) |