diff options
Diffstat (limited to 'stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux')
-rw-r--r-- | stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux b/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux index bf8e73b86..0d1148fbd 100644 --- a/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux +++ b/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux @@ -1,8 +1,7 @@ (.module: [lux #* [control - ["." monad (#+ do)] - ["ex" exception (#+ exception:)]] + ["." monad (#+ do)]] [data ["." text format] @@ -12,13 +11,15 @@ [type ["." check]] [io (#+ IO)]] - ["." //// - ["." analysis (#+ Analysis Handler Bundle) - [".A" type] - [".A" case] - [".A" function]]] ["." /// - ["." bundle]]) + ["." bundle] + ["//." // + ["." analysis (#+ Analysis Handler Bundle) + [".A" type] + [".A" case] + [".A" function]] + [// + [evaluation (#+ Eval)]]]]) ## [Utils] (def: (simple inputsT+ outputT) @@ -91,24 +92,25 @@ _ (////.throw bundle.invalid-syntax [extension-name])))) -## (do-template [<name> <type>] -## [(def: <name> -## Handler -## (function (_ extension-name analyse args) -## (case args -## (^ (list typeC valueC)) -## (do ////.Monad<Operation> -## [actualT (eval Type typeC) -## _ (typeA.infer (:coerce Type actualT))] -## (typeA.with-type <type> -## (analyse valueC))) - -## _ -## (////.throw bundle.incorrect-arity [extension-name 2 (list.size args)]))))] - -## [lux::check (:coerce Type actualT)] -## [lux::coerce Any] -## ) +(do-template [<name> <type>] + [(def: (<name> eval) + (-> Eval Handler) + (function (_ extension-name analyse args) + (case args + (^ (list typeC valueC)) + (do ////.Monad<Operation> + [actualT (:: @ map (|>> (:coerce Type)) + (eval Type typeC)) + _ (typeA.infer actualT)] + (typeA.with-type <type> + (analyse valueC))) + + _ + (////.throw bundle.incorrect-arity [extension-name 2 (list.size args)]))))] + + [lux::check actualT] + [lux::coerce Any] + ) (def: lux::check::type Handler @@ -124,13 +126,13 @@ _ (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) -(def: bundle::lux - Bundle +(def: (bundle::lux eval) + (-> Eval Bundle) (|> bundle.empty (bundle.install "is" lux::is) (bundle.install "try" lux::try) - ## (bundle.install "check" lux::check) - ## (bundle.install "coerce" lux::coerce) + (bundle.install "check" (lux::check eval)) + (bundle.install "coerce" (lux::coerce eval)) (bundle.install "check type" lux::check::type) (bundle.install "in-module" lux::in-module))) @@ -201,11 +203,11 @@ (bundle.install "clip" (trinary Text Nat Nat (type (Maybe Text)))) ))) -(def: #export bundle - Bundle +(def: #export (bundle eval) + (-> Eval Bundle) (<| (bundle.prefix "lux") (|> bundle.empty - (dict.merge bundle::lux) + (dict.merge (bundle::lux eval)) (dict.merge bundle::bit) (dict.merge bundle::int) (dict.merge bundle::frac) |