diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/source/lux/compiler.lux | 35 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default.lux | 10 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/default/phase/translation.lux | 20 | ||||
-rw-r--r-- | stdlib/source/lux/compiler/meta/io/context.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/world/file.lux | 39 |
5 files changed, 64 insertions, 42 deletions
diff --git a/stdlib/source/lux/compiler.lux b/stdlib/source/lux/compiler.lux index cdbc598bb..bc6005382 100644 --- a/stdlib/source/lux/compiler.lux +++ b/stdlib/source/lux/compiler.lux @@ -1,20 +1,41 @@ (.module: - [lux (#- Source) + [lux (#- Module Source Code) [control ["ex" exception (#+ exception:)]] + [data + ["." error (#+ Error)] + [collection + ["." dictionary (#+ Dictionary)]]] [world + ["." binary (#+ Binary)] ["." file (#+ File)]]] [/ [meta ["." archive (#+ Document Archive)]]]) +(type: #export Module Text) + +(type: #export Code Text) + (type: #export Source - {#name Text + {#module Module #file File - #code Text}) + #code Code}) + +(type: #export Output + (Dictionary File Binary)) + +(type: #export (Compilation d) + {#dependencies (List Module) + #process (-> Archive + (Error (Either (Compilation d) + [(Document d) Output])))}) + +(type: #export (Compiler d) + (-> Source (Compilation d))) -(type: #export (Compiler d !) - (-> (file.System !) Archive Source (! (Document d)))) +(type: #export (Importer !) + (-> (file.System !) Module Archive (! (Error Archive)))) -(exception: #export (cannot-compile {name Text}) - (ex.report ["Module" name])) +(exception: #export (cannot-compile {module Module}) + (ex.report ["Module" module])) diff --git a/stdlib/source/lux/compiler/default.lux b/stdlib/source/lux/compiler/default.lux index e799f0496..efba96e05 100644 --- a/stdlib/source/lux/compiler/default.lux +++ b/stdlib/source/lux/compiler/default.lux @@ -60,11 +60,11 @@ (set@ #.cursor cursor))] output]))))) -## ## (def: (write-module target-dir file-name module-name module artifacts) -## ## (-> File Text Text Module Artifacts (Process Any)) +## ## (def: (write-module target-dir file-name module-name module outputs) +## ## (-> File Text Text Module Outputs (Process Any)) ## ## (do io.Monad<Process> ## ## [_ (monad.map @ (product.uncurry (&io.write target-dir)) -## ## (dictionary.entries artifacts))] +## ## (dictionary.entries outputs))] ## ## (&io.write target-dir ## ## (format module-name "/" cache.descriptor-name) ## ## (encoding.to-utf8 (%code (cache/description.write file-name module)))))) @@ -87,7 +87,7 @@ (do phase.Monad<Operation> [_ (module.create (text/hash (get@ #//.code source)) module-name) _ (analysis.set-current-module module-name)] - (analysis.set-source-code (init.source (get@ #//.name source) (get@ #//.code source)))))) + (analysis.set-source-code (init.source (get@ #//.module source) (get@ #//.code source)))))) (def: end-module-compilation (All [anchor expression statement] @@ -136,7 +136,7 @@ (get@ #cli.sources configuration) (get@ #cli.module configuration)) ## _ (&io.prepare-module target-dir (get@ #cli.module configuration)) - ## _ (write-module target-dir file-name (get@ #cli.module configuration) module artifacts) + ## _ (write-module target-dir file-name (get@ #cli.module configuration) module outputs) ] (<| (:: @ map product.left) (:: (get@ #file-system platform) lift) diff --git a/stdlib/source/lux/compiler/default/phase/translation.lux b/stdlib/source/lux/compiler/default/phase/translation.lux index 8565cefcc..fb40f4652 100644 --- a/stdlib/source/lux/compiler/default/phase/translation.lux +++ b/stdlib/source/lux/compiler/default/phase/translation.lux @@ -41,9 +41,9 @@ (do-template [<name>] [(exception: #export (<name> {name Name}) - (ex.report ["Artifact" (%name name)]))] + (ex.report ["Output" (%name name)]))] - [cannot-overwrite-artifact] + [cannot-overwrite-output] [no-buffer-for-saving-code] ) @@ -61,14 +61,14 @@ (type: #export (Buffer statement) (Row [Name statement])) -(type: #export (Artifacts statement) (Dictionary File (Buffer statement))) +(type: #export (Outputs statement) (Dictionary File (Buffer statement))) (type: #export (State anchor expression statement) {#context Context #anchor (Maybe anchor) #host (Host expression statement) #buffer (Maybe (Buffer statement)) - #artifacts (Artifacts statement) + #outputs (Outputs statement) #counter Nat #name-cache (Dictionary Name Text)}) @@ -92,7 +92,7 @@ #anchor #.None #host host #buffer #.None - #artifacts (dictionary.new text.Hash<Text>) + #outputs (dictionary.new text.Hash<Text>) #counter 0 #name-cache (dictionary.new name.Hash<Name>)}) @@ -158,10 +158,10 @@ buffer (Buffer statement) no-active-buffer] ) -(def: #export artifacts +(def: #export outputs (All [anchor expression statement] - (Operation anchor expression statement (Artifacts statement))) - (extension.read (get@ #artifacts))) + (Operation anchor expression statement (Outputs statement))) + (extension.read (get@ #outputs))) (def: #export next (All [anchor expression statement] @@ -208,7 +208,7 @@ (case ?buffer (#.Some buffer) (if (row.any? (|>> product.left (name/= name)) buffer) - (//.throw cannot-overwrite-artifact name) + (//.throw cannot-overwrite-output name) (extension.update (set@ #buffer (#.Some (row.add [name code] buffer))))) #.None @@ -219,7 +219,7 @@ (-> File (Operation anchor expression statement Any))) (do //.Monad<Operation> [buffer ..buffer] - (extension.update (update@ #artifacts (dictionary.put target buffer))))) + (extension.update (update@ #outputs (dictionary.put target buffer))))) (def: #export (remember lux-name) (All [anchor expression statement] diff --git a/stdlib/source/lux/compiler/meta/io/context.lux b/stdlib/source/lux/compiler/meta/io/context.lux index 96a8d4835..2651c771d 100644 --- a/stdlib/source/lux/compiler/meta/io/context.lux +++ b/stdlib/source/lux/compiler/meta/io/context.lux @@ -96,7 +96,7 @@ binary (:: System<m> read file)] (case (encoding.from-utf8 binary) (#error.Success code) - (wrap {#////.name module + (wrap {#////.module module #////.file file #////.code code}) diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index 4bc2e6632..e97668917 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -27,27 +27,28 @@ #Write #Execute) -(signature: #export (System m) - (: (Monad m) +(signature: #export (System !) + (: (Monad !) &monad) - (: (All [e a] (-> (Exception e) e (m a))) + (: (All [e a] (-> (Exception e) e (! a))) throw) - (: (All [a] (-> (m a) (m (Error a)))) + (: (All [a] (-> (! a) (! (Error a)))) try) - (: (All [a] (-> (Error a) (m a))) + (: (All [a] (-> (Error a) (! a))) lift) (do-template [<name>] - [(: (-> Binary File (m Any)) + [(: (-> Binary File (! Any)) <name>)] - [append] [write]) + [append] + [write]) (do-template [<name> <output>] - [(: (-> File (m <output>)) + [(: (-> File (! <output>)) <name>)] [read Binary] @@ -56,28 +57,28 @@ [last-modified Instant]) (do-template [<name>] - [(: (-> File (m Bit)) + [(: (-> File (! Bit)) <name>)] [file?] [directory?] ) - (: (-> Permission File (m Bit)) + (: (-> Permission File (! Bit)) can?) (do-template [<name>] - [(: (-> File (m Any)) + [(: (-> File (! Any)) <name>)] [make-directory] [delete] ) - (: (-> File File (m Any)) + (: (-> File File (! Any)) move) - (: (-> Instant File (m Any)) + (: (-> Instant File (! Any)) modify) (: Text @@ -257,10 +258,10 @@ )) })) -(def: #export (exists? System<m> file) - (All [m] (-> (System m) File (m Bit))) - (do (:: System<m> &monad) - [??? (:: System<m> file? file)] +(def: #export (exists? System<!> file) + (All [!] (-> (System !) File (! Bit))) + (do (:: System<!> &monad) + [??? (:: System<!> file? file)] (if ??? - (wrap #1) - (:: System<m> directory? file)))) + (wrap ???) + (:: System<!> directory? file)))) |