diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux b/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux index c315f8d9d..e6a58e3b7 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension/analysis/common.lux @@ -94,26 +94,38 @@ _ (/////analysis.throw ///.invalid-syntax [extension-name %code argsC+])))) -(template [<name> <type>] - [(def: (<name> eval) - (-> Eval Handler) - (function (_ extension-name analyse args) - (case args - (^ (list typeC valueC)) - (do ////.monad - [count (///.lift macro.count) - actualT (:: @ map (|>> (:coerce Type)) - (eval count Type typeC)) - _ (typeA.infer actualT)] - (typeA.with-type <type> - (analyse valueC))) - - _ - (/////analysis.throw ///.incorrect-arity [extension-name 2 (list.size args)]))))] - - [lux::check actualT] - [lux::coerce Any] - ) +(def: (lux::check eval) + (-> Eval Handler) + (function (_ extension-name analyse args) + (case args + (^ (list typeC valueC)) + (do ////.monad + [count (///.lift macro.count) + actualT (:: @ map (|>> (:coerce Type)) + (eval count Type typeC)) + _ (typeA.infer actualT)] + (typeA.with-type actualT + (analyse valueC))) + + _ + (/////analysis.throw ///.incorrect-arity [extension-name 2 (list.size args)])))) + +(def: (lux::coerce eval) + (-> Eval Handler) + (function (_ extension-name analyse args) + (case args + (^ (list typeC valueC)) + (do ////.monad + [count (///.lift macro.count) + actualT (:: @ map (|>> (:coerce Type)) + (eval count Type typeC)) + _ (typeA.infer actualT) + [valueT valueA] (typeA.with-inference + (analyse valueC))] + (wrap valueA)) + + _ + (/////analysis.throw ///.incorrect-arity [extension-name 2 (list.size args)])))) (def: (caster input output) (-> Type Type Handler) |