(.module: [library [lux {"-" [Module]} [type {"+" [:sharing]}] ["@" target] ["[0]" debug] [abstract [monad {"+" [do]}]] [control ["[0]" io {"+" [IO io]}] ["[0]" try {"+" [Try]}] [concurrency ["[0]" async {"+" [Async]} ("[1]\[0]" monad)]]] [data [binary {"+" [Binary]}] ["[0]" product] ["[0]" text ["%" format {"+" [format]}]] [collection ["[0]" dictionary {"+" [Dictionary]}] ["[0]" row {"+" [Row]}]]] [time ["[0]" instant]] ["[0]" world "_" ["[0]" file] ["[1]/[0]" program] ... ["[0]" console] ] [tool [compiler ["[0]" phase] [default ["[0]" platform {"+" [Platform]}]] [language ["$" lux ["[1]/[0]" program {"+" [Program]}] ["[0]" syntax] ["[0]" analysis [macro {"+" [Expander]}]] ["[0]" generation {"+" [Buffer Context]}] ["[0]" directive] [phase [extension {"+" [Extender]}]]]] [meta [packager {"+" [Packager]}] [archive {"+" [Archive]} [descriptor {"+" [Module]}]] [cache ["[0]" dependency]] [io ["ioW" archive]]]] ... ["[0]" interpreter] ]]] ["[0]" / "_" ["[1][0]" cli {"+" [Service]}] ["[1][0]" static {"+" [Static]}] ["[1][0]" export] ["[1][0]" import]]) (def: (or_crash! failure_description action) (All (_ a) (-> Text (Async (Try a)) (Async a))) (do async.monad [?output action] (case ?output (#try.Failure error) (exec (debug.log! (format text.new_line failure_description text.new_line error text.new_line)) (io.run! (\ world/program.default exit +1))) (#try.Success output) (in output)))) (def: (timed process) (All (_ a) (-> (Async (Try a)) (Async (Try a)))) (do async.monad [.let [start (io.run! instant.now)] output process .let [_ ("lux io log" (|> (io.run! instant.now) (instant.span start) %.duration (format "Duration: ")))]] (in output))) (def: (package! fs host_dependencies [packager package] static archive context) (-> (file.System Async) (Dictionary file.Path Binary) [Packager file.Path] Static Archive Context (Async (Try Any))) (case (packager host_dependencies archive context) (#try.Success content) (\ fs write content package) (#try.Failure error) (\ async.monad in (#try.Failure error)))) (def: (load_host_dependencies fs host_dependencies) (-> (file.System Async) (List file.Path) (Async (Try (Dictionary file.Path Binary)))) (do [! (try.with async.monad)] [] (loop [pending host_dependencies output (: (Dictionary file.Path Binary) (dictionary.empty text.hash))] (case pending #.End (in output) (#.Item head tail) (do ! [content (\ fs read head)] (recur tail (dictionary.has head content output))))))) (with_expansions [ (as_is anchor expression artifact)] (def: .public (compiler static expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender service packager,package) (All (_ ) (-> Static Expander analysis.Bundle (IO (Platform )) (generation.Bundle ) (-> phase.Wrapper (directive.Bundle )) (Program expression artifact) [Type Type Type] (-> phase.Wrapper Extender) Service [Packager file.Path] (Async Any))) (do [! async.monad] [platform (async.future platform)] (case service (#/cli.Compilation compilation) (<| (or_crash! "Compilation failed:") ..timed (do (try.with async.monad) [.let [[compilation_sources compilation_host_dependencies compilation_libraries compilation_target compilation_module] compilation] import (/import.import (value@ #platform.&file_system platform) compilation_libraries) [state archive phase_wrapper] (:sharing [] (Platform ) platform (Async (Try [(directive.State+ ) Archive phase.Wrapper])) (:expected (platform.initialize static compilation_module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender import compilation_sources))) [archive state] (:sharing [] (Platform ) platform (Async (Try [Archive (directive.State+ )])) (:expected (platform.compile phase_wrapper import static expander platform compilation [archive state]))) _ (ioW.freeze (value@ #platform.&file_system platform) static archive) program_context (async\in ($/program.context archive)) host_dependencies (..load_host_dependencies (value@ #platform.&file_system platform) compilation_host_dependencies) _ (..package! (for [@.old (file.async file.default) @.jvm (file.async file.default) @.js file.default]) host_dependencies packager,package static archive program_context)] (in (debug.log! "Compilation complete!")))) (#/cli.Export export) (<| (or_crash! "Export failed:") (do (try.with async.monad) [_ (/export.export (value@ #platform.&file_system platform) export)] (in (debug.log! "Export complete!")))) (#/cli.Interpretation interpretation) ... TODO: Fix the interpreter... (undefined) ... (<| (or_crash! "Interpretation failed:") ... (do [! async.monad] ... [console (|> console.default ... async.future ... (\ ! each (|>> try.trusted console.async)))] ... (interpreter.run! (try.with async.monad) console platform interpretation generation_bundle))) ))))