diff options
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase')
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/extension/statement.lux | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux index 6c2ba872f..7deb93696 100644 --- a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux +++ b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux @@ -17,7 +17,7 @@ ["." dictionary]]] ["." macro ["." code]] - [type (#+ :share :by-example) + ["." type (#+ :share :by-example) ("#@." equivalence) ["." check]]] ["." // ["#." bundle] @@ -27,7 +27,7 @@ ["#." generation] [analysis ["." module] - ["." type]] + [".A" type]] ["#/" // #_ ["#." analysis] ["#." synthesis (#+ Synthesis)] @@ -59,8 +59,8 @@ generate (get@ [#////statement.generation #////statement.phase] state)] [_ code//type codeA] (////statement.lift-analysis (////analysis.with-scope - (type.with-fresh-env - (type.with-type type + (typeA.with-fresh-env + (typeA.with-type type (do @ [codeA (analyse codeC)] (wrap [type codeA])))))) @@ -83,9 +83,9 @@ _ (///generation.save! false name statement)] (wrap [code//type codeT target-name value])))) -(def: (definition name ?type codeC) +(def: (definition name codeC) (All [anchor expression statement] - (-> Name (Maybe Type) Code + (-> Name Code (Operation anchor expression statement [Type expression Text Any]))) (do ///.monad [state (//.lift ///.get-state) @@ -94,20 +94,12 @@ generate (get@ [#////statement.generation #////statement.phase] state)] [_ code//type codeA] (////statement.lift-analysis (////analysis.with-scope - (type.with-fresh-env - (case ?type - (#.Some type) - (type.with-type type - (do @ - [codeA (analyse codeC)] - (wrap [type codeA]))) - - #.None - (do @ - [[code//type codeA] (type.with-inference (analyse codeC)) - code//type (type.with-env - (check.clean code//type))] - (wrap [code//type codeA])))))) + (typeA.with-fresh-env + (do @ + [[code//type codeA] (typeA.with-inference (analyse codeC)) + code//type (typeA.with-env + (check.clean code//type))] + (wrap [code//type codeA]))))) codeS (////statement.lift-synthesis (synthesize codeA))] (definition' generate name code//type codeS))) @@ -119,7 +111,7 @@ (////statement.lift-analysis (do ///.monad [_ (module.define short-name [type annotations value])] - (if (macro.type? annotations) + (if (type@= .Type type) (case (macro.declared-tags annotations) #.Nil (wrap []) @@ -155,11 +147,7 @@ #let [full-name [current-module short-name]] [_ annotationsT annotationsV] (evaluate! Code annotationsC) #let [annotationsV (:coerce Code annotationsV)] - [value//type valueT valueN valueV] (..definition full-name - (if (macro.type? annotationsV) - (#.Some Type) - #.None) - valueC) + [value//type valueT valueN valueV] (..definition full-name valueC) _ (..define short-name value//type annotationsV valueV) #let [_ (log! (format "Definition " (%name full-name)))] _ (////statement.lift-generation @@ -282,8 +270,8 @@ (do ///.monad [[_ programA] (////statement.lift-analysis (////analysis.with-scope - (type.with-fresh-env - (type.with-type (type (-> (List Text) (IO Any))) + (typeA.with-fresh-env + (typeA.with-type (type (-> (List Text) (IO Any))) (analyse programC)))))] (////statement.lift-synthesis (synthesize programA)))) |