diff options
author | Eduardo Julian | 2022-11-28 15:35:57 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-11-28 15:35:57 -0400 |
commit | 8059ba6c421d3094fba336ac5d3dd39fe984b05e (patch) | |
tree | 416a27d5a5ae1db02afb2caa681c6e321c7b8f90 /stdlib/source/library | |
parent | 09a29c952edb851e13edd454bd118c1c1ae83ade (diff) |
Added currencies.
Diffstat (limited to 'stdlib/source/library')
19 files changed, 654 insertions, 369 deletions
diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index c0273bf85..5732efe88 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -245,7 +245,7 @@ ... TODO @.lua @.ruby (as Text - ("ruby object do" "gsub" template [pattern replacement])) + (.ruby_object_do# "gsub" template [pattern replacement])) @.php (as Text ("php apply" (as_expected ("php constant" "str_replace")) @@ -374,7 +374,7 @@ (.lua_apply# (.lua_constant# "string.lower") [value])) @.ruby (as Text - ("ruby object do" "downcase" value [])))) + (.ruby_object_do# "downcase" value [])))) (def .public (upper_cased value) (-> Text Text) @@ -397,4 +397,4 @@ (.lua_apply# (.lua_constant# "string.upper") [value])) @.ruby (as Text - ("ruby object do" "upcase" value [])))) + (.ruby_object_do# "upcase" value [])))) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 25b040c90..a763188ad 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -302,18 +302,18 @@ [+1 Int %.int] [+1.0 Frac %.frac] ["" Text %.text] - [("ruby object nil") Any (pipe.new "nil" [])] + [(.ruby_object_nil#) Any (pipe.new "nil" [])] )) (same? (class_of {.#None}) value_class) - (let [variant_tag ("ruby object get" "_lux_tag" value) - variant_flag ("ruby object get" "_lux_flag" value) - variant_value ("ruby object get" "_lux_value" value)] - (if (or ("ruby object nil?" variant_tag) - ("ruby object nil?" variant_value)) + (let [variant_tag (.ruby_object_get# "_lux_tag" value) + variant_flag (.ruby_object_get# "_lux_flag" value) + variant_value (.ruby_object_get# "_lux_value" value)] + (if (or (.ruby_object_nil?# variant_tag) + (.ruby_object_nil?# variant_value)) (tuple_inspection inspection value) (|> (%.format (|> variant_tag (as .Nat) %.nat) - " " (%.bit (not ("ruby object nil?" variant_flag))) + " " (%.bit (not (.ruby_object_nil?# variant_flag))) " " (inspection variant_value)) (text.enclosed ["{" "}"])))) diff --git a/stdlib/source/library/lux/ffi.lux b/stdlib/source/library/lux/ffi.lux index fb5270605..c515749a9 100644 --- a/stdlib/source/library/lux/ffi.lux +++ b/stdlib/source/library/lux/ffi.lux @@ -189,29 +189,29 @@ (with_expansions [<constant> (for @.js "js constant" @.python .python_constant# @.lua .lua_constant# - @.ruby "ruby constant") + @.ruby .ruby_constant#) <apply> (for @.js "js apply" @.python .python_apply# @.lua .lua_apply# - @.ruby "ruby apply") + @.ruby .ruby_apply#) <new> (for @.js "js object new" @.python .python_apply# (these)) <do> (for @.js "js object do" @.python .python_object_do# @.lua .lua_object_do# - @.ruby "ruby object do") + @.ruby .ruby_object_do#) <get> (for @.js "js object get" @.python .python_object_get# @.lua .lua_object_get# - @.ruby "ruby object get" + @.ruby .ruby_object_get# (these)) <set> (for @.lua .lua_object_set# - @.ruby "ruby object set" + @.ruby .ruby_object_set# (these)) <import> (for @.python .python_import# @.lua .lua_import# - @.ruby "ruby import" + @.ruby .ruby_import# (these)) <function> (for @.js "js function" @.python .python_function# @@ -466,8 +466,8 @@ none? .python_object_none?#] @.lua [nil .lua_object_nil# nil? .lua_object_nil?#] - @.ruby [nil "ruby object nil" - nil? "ruby object nil?"])) + @.ruby [nil .ruby_object_nil# + nil? .ruby_object_nil?#])) )) (type Declaration diff --git a/stdlib/source/library/lux/ffi/export.lua.lux b/stdlib/source/library/lux/ffi/export.lua.lux index 54aa573b6..62f83554c 100644 --- a/stdlib/source/library/lux/ffi/export.lua.lux +++ b/stdlib/source/library/lux/ffi/export.lua.lux @@ -11,8 +11,6 @@ [collection ["[0]" list (.use "[1]#[0]" monad mix)] ["[0]" set]]] - [math - ["[0]" random]] ["[0]" meta (.only) [extension (.only declaration)] ["[0]" code (.only) diff --git a/stdlib/source/library/lux/ffi/export.rb.lux b/stdlib/source/library/lux/ffi/export.rb.lux index 023338afe..fe08e1fc7 100644 --- a/stdlib/source/library/lux/ffi/export.rb.lux +++ b/stdlib/source/library/lux/ffi/export.rb.lux @@ -12,11 +12,8 @@ [collection ["[0]" list (.use "[1]#[0]" monad mix)] ["[0]" set]]] - [math - ["[0]" random]] ["[0]" meta (.only) [extension (.only declaration)] - ["[0]" static] ["[0]" type] ["[0]" code (.only) ["<[1]>" \\parser]] @@ -85,20 +82,20 @@ <code>.any))) meta.of_try)) -(with_expansions [<extension> (static.random (|>> %.nat (%.format "ruby export ") code.text) - random.nat)] - (declaration (<extension> self phase archive [global? <code>.bit - name <code>.text - term <code>.any]) +(def .public export_one + (declaration (_ phase archive [global? <code>.bit + name <code>.text + term <code>.any]) (do [! phase.monad] [next declaration.analysis [type term] (<| declaration.of_analysis analysis.inferring (next archive term)) + lux (declaration.of_analysis meta.compiler_state) next declaration.synthesis term (declaration.of_synthesis - (next archive term)) + (next lux archive term)) dependencies (declaration.of_translation (dependency.dependencies archive term)) @@ -106,7 +103,7 @@ next declaration.translation [interim_artifacts term] (declaration.of_translation (translation.with_interim_artifacts archive - (next archive term))) + (next lux archive term))) _ (declaration.of_translation (do ! @@ -125,21 +122,21 @@ _ (translation.execute! code) _ (translation.save! @self {.#None} code)] (translation.log! (%.format "Export " (%.text name)))))] - (in declaration.no_requirements))) + (in declaration.no_requirements)))) - (def .public export - (syntax (_ [exports (<>.many <code>.any)]) - (let [! meta.monad] - (|> exports - (monad.each ! expansion.complete) - (at ! each (|>> list#conjoint - (monad.each ! ..definition))) - (at ! conjoint) - (at ! each (list#each (function (_ [name term]) - (` (<extension> (,* (when name - {#Method name} - (list (code.bit false) (code.text name)) - - {#Global name} - (list (code.bit true) (code.text name)))) - (, term))))))))))) +(def .public export + (syntax (_ [exports (<>.many <code>.any)]) + (let [! meta.monad] + (|> exports + (monad.each ! expansion.complete) + (at ! each (|>> list#conjoint + (monad.each ! ..definition))) + (at ! conjoint) + (at ! each (list#each (function (_ [name term]) + (` (export_one (,* (when name + {#Method name} + (list (code.bit false) (code.text name)) + + {#Global name} + (list (code.bit true) (code.text name)))) + (, term)))))))))) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index d3ec7c660..228de8764 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -236,7 +236,7 @@ (-> Frac Frac) (|>> [] - ("ruby apply" ("ruby constant" <method>)) + (.ruby_apply# (.ruby_constant# <method>)) (as Frac)))] [cos "Math.cos"] @@ -258,7 +258,7 @@ [(def .public (<name> it) (-> Frac Frac) - (|> ("ruby object do" <method> it []) + (|> (.ruby_object_do# <method> it []) (as Int) (.int_f64#)))] @@ -269,7 +269,7 @@ (def .public (pow param subject) (-> Frac Frac Frac) - (as Frac ("ruby object do" "**" subject [param])))) + (as Frac (.ruby_object_do# "**" subject [param])))) @.php (these (with_template [<name> <method>] diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/ruby.lux index cf07042d4..de66972a1 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -11,7 +11,7 @@ ["[0]" array] ["[0]" dictionary] ["[0]" list]]] - [meta + ["[0]" meta (.only) ["@" target (.only) ["_" ruby]] ["[0]" code @@ -20,16 +20,16 @@ ["[0]" check]]]]] [// ["/" lux (.only custom)] - [// - ["[0]" bundle] - [/// + [/// + ["[0]" extension] + [// ["[0]" analysis (.only Analysis Operation Phase Handler Bundle) ["[1]/[0]" type]] [/// ["[0]" phase]]]]]) (def array::new - Handler + (-> Text Handler) (custom [<code>.any (function (_ extension phase archive lengthC) @@ -40,11 +40,13 @@ (do phase.monad [lengthA (<| (analysis/type.expecting Nat) (phase archive lengthC)) - _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))] - (in {analysis.#Extension extension (list lengthA)}))))])) + _ (analysis/type.inference (type_literal (array.Array' :read: :write:))) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list lengthA)}]))))])) (def array::length - Handler + (-> Text Handler) (custom [<code>.any (function (_ extension phase archive arrayC) @@ -55,11 +57,13 @@ (do phase.monad [arrayA (<| (analysis/type.expecting (type_literal (array.Array' :read: :write:))) (phase archive arrayC)) - _ (analysis/type.inference Nat)] - (in {analysis.#Extension extension (list arrayA)}))))])) + _ (analysis/type.inference Nat) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list arrayA)}]))))])) (def array::read - Handler + (-> Text Handler) (custom [(<>.and <code>.any <code>.any) (function (_ extension phase archive [indexC arrayC]) @@ -72,11 +76,13 @@ (phase archive indexC)) arrayA (<| (analysis/type.expecting (type_literal (array.Array' :read: :write:))) (phase archive arrayC)) - _ (analysis/type.inference :read:)] - (in {analysis.#Extension extension (list indexA arrayA)}))))])) + _ (analysis/type.inference :read:) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list indexA arrayA)}]))))])) (def array::write - Handler + (-> Text Handler) (custom [(all <>.and <code>.any <code>.any <code>.any) (function (_ extension phase archive [indexC valueC arrayC]) @@ -91,11 +97,13 @@ (phase archive valueC)) arrayA (<| (analysis/type.expecting (type_literal (array.Array' :read: :write:))) (phase archive arrayC)) - _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))] - (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) + _ (analysis/type.inference (type_literal (array.Array' :read: :write:))) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list indexA valueA arrayA)}]))))])) (def array::delete - Handler + (-> Text Handler) (custom [(all <>.and <code>.any <code>.any) (function (_ extension phase archive [indexC arrayC]) @@ -108,19 +116,19 @@ (phase archive indexC)) arrayA (<| (analysis/type.expecting (type_literal (array.Array' :read: :write:))) (phase archive arrayC)) - _ (analysis/type.inference (type_literal (array.Array' :read: :write:)))] - (in {analysis.#Extension extension (list indexA arrayA)}))))])) - -(def bundle::array - Bundle - (<| (bundle.prefix "array") - (|> bundle.empty - (bundle.install "new" array::new) - (bundle.install "length" array::length) - (bundle.install "read" array::read) - (bundle.install "write" array::write) - (bundle.install "delete" array::delete) - ))) + _ (analysis/type.inference (type_literal (array.Array' :read: :write:))) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list indexA arrayA)}]))))])) + +(def with_array_extensions + (-> Bundle Bundle) + (|>> (/.install "ruby_array_new#" array::new) + (/.install "ruby_array_length#" array::length) + (/.install "ruby_array_read#" array::read) + (/.install "ruby_array_write#" array::write) + (/.install "ruby_array_delete#" array::delete) + )) (def Nil (for @.ruby ffi.Nil @@ -135,19 +143,21 @@ Any)) (def object::get - Handler + (-> Text Handler) (custom [(all <>.and <code>.text <code>.any) (function (_ extension phase archive [fieldC objectC]) (do phase.monad [objectA (<| (analysis/type.expecting ..Object) (phase archive objectC)) - _ (analysis/type.inference .Any)] - (in {analysis.#Extension extension (list (analysis.text fieldC) - objectA)})))])) + _ (analysis/type.inference .Any) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list (analysis.text @ fieldC) + objectA)}])))])) (def object::do - Handler + (-> Text Handler) (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) (function (_ extension phase archive [methodC objectC inputsC]) @@ -155,32 +165,34 @@ [objectA (<| (analysis/type.expecting ..Object) (phase archive objectC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) - _ (analysis/type.inference .Any)] - (in {analysis.#Extension extension (list.partial (analysis.text methodC) - objectA - inputsA)})))])) - -(def bundle::object - Bundle - (<| (bundle.prefix "object") - (|> bundle.empty - (bundle.install "get" object::get) - (bundle.install "do" object::do) - (bundle.install "nil" (/.nullary ..Nil)) - (bundle.install "nil?" (/.unary Any Bit)) - ))) + _ (analysis/type.inference .Any) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list.partial (analysis.text @ methodC) + objectA + inputsA)}])))])) + +(def with_object_extensions + (-> Bundle Bundle) + (|>> (/.install "ruby_object_get#" object::get) + (/.install "ruby_object_do#" object::do) + (/.install "ruby_object_nil#" (/.nullary ..Nil)) + (/.install "ruby_object_nil?#" (/.unary Any Bit)) + )) (def ruby::constant - Handler + (-> Text Handler) (custom [<code>.text (function (_ extension phase archive name) (do phase.monad - [_ (analysis/type.inference Any)] - (in {analysis.#Extension extension (list (analysis.text name))})))])) + [_ (analysis/type.inference Any) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list (analysis.text @ name))}])))])) (def ruby::apply - Handler + (-> Text Handler) (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) (function (_ extension phase archive [abstractionC inputsC]) @@ -188,27 +200,30 @@ [abstractionA (<| (analysis/type.expecting ..Function) (phase archive abstractionC)) inputsA (monad.each ! (|>> (phase archive) (analysis/type.expecting Any)) inputsC) - _ (analysis/type.inference Any)] - (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) + _ (analysis/type.inference Any) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list.partial abstractionA inputsA)}])))])) (def ruby::import - Handler + (-> Text Handler) (custom [<code>.text (function (_ extension phase archive name) (do phase.monad - [_ (analysis/type.inference Bit)] - (in {analysis.#Extension extension (list (analysis.text name))})))])) + [_ (analysis/type.inference Bit) + @ meta.location] + (in [@ {analysis.#Extension (/.translation extension) + (list (analysis.text @ name))}])))])) (def .public bundle Bundle - (<| (bundle.prefix "ruby") - (|> bundle.empty - (dictionary.composite bundle::array) - (dictionary.composite bundle::object) - - (bundle.install "constant" ruby::constant) - (bundle.install "apply" ruby::apply) - (bundle.install "import" ruby::import) - (bundle.install "script universe" (/.nullary .Bit)) - ))) + (|> extension.empty + with_array_extensions + with_object_extensions + + (/.install "ruby_constant#" ruby::constant) + (/.install "ruby_apply#" ruby::apply) + (/.install "ruby_import#" ruby::import) + (/.install "ruby_script_universe#" (/.nullary .Bit)) + )) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/lua/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/lua/common.lux index 89c91235d..e278cd290 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/lua/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/lua/common.lux @@ -5,6 +5,7 @@ ["[0]" monad (.only do)]] [control ["<>" parser] + ["|" pipe] ["[0]" function] ["[0]" try]] [data @@ -114,7 +115,7 @@ )) ... TODO: Get rid of this ASAP -(def lux::syntax_char_case! +(def lux//syntax_char_case! (..custom [(all <>.and ?synthesis.any ?synthesis.any @@ -145,7 +146,7 @@ (def with_basic_extensions (-> Bundle Bundle) - (|>> (dictionary.has "when_char#|translation" lux::syntax_char_case!) + (|>> (dictionary.has "when_char#|translation" lux//syntax_char_case!) (dictionary.has "is?#|translation" (binary (product.uncurried _.=))) (dictionary.has "try#|translation" (unary //runtime.lux//try)))) @@ -204,20 +205,26 @@ (Trinary Expression) (//runtime.text//index textO partO startO)) -(def (text::composite parts) +(def text//composite (Variadic Expression) - (when parts - (list) - (_.string "") + (|>> (|.when (list) + (_.string "") - (list.partial head tail) - (list#mix _.concat head tail))) + (list single) + single + + (list left right) + (|> left (_.concat right)) + + parts + (_.apply (list (_.array parts)) + (_.var "table.concat"))))) (def with_text_extensions (-> Bundle Bundle) (|>> (dictionary.has "text_=#|translation" (binary (product.uncurried _.=))) (dictionary.has "text_<#|translation" (binary (product.uncurried _.<))) - (dictionary.has "text_composite#|translation" (variadic ..text::composite)) + (dictionary.has "text_composite#|translation" (variadic ..text//composite)) (dictionary.has "text_index#|translation" (trinary ..text//index)) (dictionary.has "text_size#|translation" (unary //runtime.text//size)) ... TODO: Use version below once the Lua compiler becomes self-hosted. diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux index edabbd255..53ddeaa57 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/common.lux @@ -5,6 +5,7 @@ ["[0]" monad (.only do)]] [control ["<>" parser] + ["|" pipe] ["[0]" function] ["[0]" try]] [data @@ -47,6 +48,19 @@ [/// ["[0]" phase (.use "[1]#[0]" monad)]]]]) +(def .public (custom [parser handler]) + (All (_ s) + (-> [(Parser s) + (-> Phase Archive s (Operation (Expression Any)))] + Handler)) + (function (_ phase archive input) + (when (<synthesis>.result parser input) + {try.#Success input'} + (handler phase archive input') + + {try.#Failure error} + (phase.failure error)))) + (def .public (statement expression archive synthesis) Phase! (when synthesis @@ -90,19 +104,6 @@ (phase#each _.return (//function.function statement expression archive abstraction)) )) -(def .public (custom [parser handler]) - (All (_ s) - (-> [(Parser s) - (-> Phase Archive s (Operation (Expression Any)))] - Handler)) - (function (_ phase archive input) - (when (<synthesis>.result parser input) - {try.#Success input'} - (handler phase archive input') - - {try.#Failure error} - (phase.failure error)))) - ... TODO: Get rid of this ASAP (def lux::syntax_char_case! (..custom [(all <>.and @@ -216,17 +217,19 @@ (Trinary (Expression Any)) (//runtime.text::index startO partO textO)) -(def (text::composite parts) +(def text::composite (Variadic (Expression Any)) - (when parts - (list) - (_.string "") + (|>> (|.when (list) + (_.string "") + + (list single) + single - (list single) - single + (list left right) + (|> left (_.+ right)) - _ - (_.do "join" (list (_.list parts)) (_.string "")))) + parts + (_.do "join" (list (_.list parts)) (_.string ""))))) (def with_text_extensions (-> Bundle Bundle) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/ruby/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/ruby/common.lux index a080ff33f..6e34a490a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/ruby/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/ruby/common.lux @@ -5,6 +5,7 @@ ["[0]" monad (.only do)]] [control ["<>" parser] + ["|" pipe] ["[0]" function] ["[0]" try]] [data @@ -21,42 +22,57 @@ [macro ["^" pattern]] [target - ["_" ruby (.only Expression Statement)]]]]] - ["[0]" //// - ["/" bundle] - ["/[1]" // - ["[0]" extension] - [translation - [extension (.only Nullary Unary Binary Trinary - nullary unary binary trinary)] - ["//" ruby - ["[1][0]" runtime (.only Operation Phase Phase! Handler Bundle Translator)] - ["[1][0]" primitive] - ["[1][0]" structure] - ["[1][0]" reference] - ["[1][0]" function] - ["[1][0]" when] - ["[1][0]" loop]]] - [// - ["[0]" translation] - ["[0]" synthesis (.only %synthesis) - ["<s>" \\parser (.only Parser)]] - [/// - ["[1]" phase (.use "[1]#[0]" monad)]]]]]) + ["_" ruby (.only Expression Statement)]] + [compiler + [meta + [archive (.only Archive)]]]]]] + [///// + ["[0]" extension] + [translation + [extension (.only Nullary Unary Binary Trinary Variadic + nullary unary binary trinary variadic)] + ["//" ruby + ["[1][0]" runtime (.only Operation Phase Phase! Handler Bundle Translator)] + ["[1][0]" primitive] + ["[1][0]" structure] + ["[1][0]" reference] + ["[1][0]" function] + ["[1][0]" when] + ["[1][0]" loop]]] + [// + ["[0]" translation] + ["[0]" synthesis (.only %synthesis) + ["<[1]>" \\parser (.only Parser)]] + [/// + ["[0]" phase (.use "[1]#[0]" monad)]]]]) + +(def .public (custom [parser handler]) + (All (_ s) + (-> [(Parser s) + (-> Phase Archive s (Operation Expression))] + Handler)) + (function (_ phase archive input) + (when (<synthesis>.result parser input) + {try.#Success input'} + (handler phase archive input') + + {try.#Failure error} + (phase.failure error)))) (def .public (statement expression archive synthesis) Phase! (when synthesis ... TODO: Get rid of this ASAP - {synthesis.#Extension [.prelude "when_char#|translation"] parameters} - (do /////.monad + [@ {synthesis.#Extension [.prelude "when_char#|translation"] parameters}] + (do phase.monad [body (expression archive synthesis)] (in (as Statement body))) (^.with_template [<tag>] - [(<tag> value) - (/////#each _.return (expression archive synthesis))]) + [(<tag> @ value) + (phase#each _.return + (expression archive synthesis))]) ([synthesis.bit] [synthesis.i64] [synthesis.f64] @@ -67,16 +83,17 @@ [synthesis.function/apply]) (^.with_template [<tag>] - [{<tag> value} - (/////#each _.return (expression archive synthesis))]) + [[@ {<tag> value}] + (phase#each _.return + (expression archive synthesis))]) ([synthesis.#Reference] [synthesis.#Extension]) - (synthesis.branch/when when) + (synthesis.branch/when @ when) (//when.when! false statement expression archive when) (^.with_template [<tag> <translator>] - [(<tag> value) + [(<tag> @ value) (<translator> statement expression archive value)]) ([synthesis.branch/exec //when.exec!] [synthesis.branch/let //when.let!] @@ -84,20 +101,21 @@ [synthesis.loop/scope //loop.scope!] [synthesis.loop/again //loop.again!]) - (synthesis.function/abstraction abstraction) - (/////#each _.return (//function.function statement expression archive abstraction)) + (synthesis.function/abstraction @ abstraction) + (phase#each _.return + (//function.function statement expression archive abstraction)) )) ... TODO: Get rid of this ASAP (def lux::syntax_char_case! (..custom [(all <>.and - <s>.any - <s>.any - (<>.some (<s>.tuple (all <>.and - (<s>.tuple (<>.many <s>.i64)) - <s>.any)))) - (function (_ extension_name phase archive [input else conditionals]) - (do [! /////.monad] + <synthesis>.any + <synthesis>.any + (<>.some (<synthesis>.tuple (all <>.and + (<synthesis>.tuple (<>.many <synthesis>.i64)) + <synthesis>.any)))) + (function (_ phase archive [input else conditionals]) + (do [! phase.monad] [inputG (phase archive input) else! (statement phase archive else) @input (at ! each _.local (translation.symbol "input")) @@ -130,52 +148,51 @@ else! conditionals!))))))])) -(def lux_procs - Bundle - (|> /.empty - (/.install "syntax char case!" lux::syntax_char_case!) - (/.install "is" (binary (function (_ [reference subject]) - (_.do "equal?" (list reference) {.#None} subject)))) - (/.install "try" (unary //runtime.lux//try)))) +(def with_basic_extensions + (-> Bundle Bundle) + (|>> (dictionary.has "when_char#|translation" lux::syntax_char_case!) + (dictionary.has "is?#|translation" (binary (function (_ [reference subject]) + (_.do "equal?" (list reference) {.#None} subject)))) + (dictionary.has "try#|translation" (unary //runtime.lux//try)))) -(def i64_procs - Bundle - (<| (/.prefix "i64") - (|> /.empty - (/.install "and" (binary (product.uncurried //runtime.i64::and))) - (/.install "or" (binary (product.uncurried //runtime.i64::or))) - (/.install "xor" (binary (product.uncurried //runtime.i64::xor))) - (/.install "left-shift" (binary (product.uncurried //runtime.i64::left_shifted))) - (/.install "right-shift" (binary (product.uncurried //runtime.i64::right_shifted))) - - (/.install "<" (binary (product.uncurried _.<))) - (/.install "=" (binary (product.uncurried _.=))) - (/.install "+" (binary (product.uncurried //runtime.i64::+))) - (/.install "-" (binary (product.uncurried //runtime.i64::-))) - (/.install "*" (binary (product.uncurried //runtime.i64::*))) - (/.install "/" (binary (product.uncurried //runtime.i64::/))) - (/.install "%" (binary (function (_ [parameter subject]) - (_.do "remainder" (list parameter) {.#None} subject)))) - - (/.install "f64" (unary (_./ (_.float +1.0)))) - (/.install "char" (unary //runtime.i64::char)) - ))) - -(def f64_procs - Bundle - (<| (/.prefix "f64") - (|> /.empty - (/.install "+" (binary (product.uncurried _.+))) - (/.install "-" (binary (product.uncurried _.-))) - (/.install "*" (binary (product.uncurried _.*))) - (/.install "/" (binary (product.uncurried _./))) - (/.install "%" (binary (function (_ [parameter subject]) - (_.do "remainder" (list parameter) {.#None} subject)))) - (/.install "=" (binary (product.uncurried _.=))) - (/.install "<" (binary (product.uncurried _.<))) - (/.install "i64" (unary (_.do "floor" (list) {.#None}))) - (/.install "encode" (unary (_.do "to_s" (list) {.#None}))) - (/.install "decode" (unary //runtime.f64//decode))))) +(def with_i64_extensions + (-> Bundle Bundle) + (|>> (dictionary.has "i64_and#|translation" (binary (product.uncurried //runtime.i64::and))) + (dictionary.has "i64_or#|translation" (binary (product.uncurried //runtime.i64::or))) + (dictionary.has "i64_xor#|translation" (binary (product.uncurried //runtime.i64::xor))) + (dictionary.has "i64_left#|translation" (binary (product.uncurried //runtime.i64::left_shifted))) + (dictionary.has "i64_right#|translation" (binary (product.uncurried //runtime.i64::right_shifted))) + + (dictionary.has "i64_=#|translation" (binary (product.uncurried _.=))) + (dictionary.has "i64_+#|translation" (binary (product.uncurried //runtime.i64::+))) + (dictionary.has "i64_-#|translation" (binary (product.uncurried //runtime.i64::-))) + )) + +(def with_int_extensions + (-> Bundle Bundle) + (|>> (dictionary.has "int_<#|translation" (binary (product.uncurried _.<))) + (dictionary.has "int_*#|translation" (binary (product.uncurried //runtime.i64::*))) + (dictionary.has "int_/#|translation" (binary (product.uncurried //runtime.i64::/))) + (dictionary.has "int_%#|translation" (binary (function (_ [parameter subject]) + (_.do "remainder" (list parameter) {.#None} subject)))) + + (dictionary.has "int_f64#|translation" (unary (_./ (_.float +1.0)))) + (dictionary.has "int_char#|translation" (unary //runtime.i64::char)) + )) + +(def with_f64_extensions + (-> Bundle Bundle) + (|>> (dictionary.has "f64_+#|translation" (binary (product.uncurried _.+))) + (dictionary.has "f64_-#|translation" (binary (product.uncurried _.-))) + (dictionary.has "f64_*#|translation" (binary (product.uncurried _.*))) + (dictionary.has "f64_/#|translation" (binary (product.uncurried _./))) + (dictionary.has "f64_%#|translation" (binary (function (_ [parameter subject]) + (_.do "remainder" (list parameter) {.#None} subject)))) + (dictionary.has "f64_=#|translation" (binary (product.uncurried _.=))) + (dictionary.has "f64_<#|translation" (binary (product.uncurried _.<))) + (dictionary.has "f64_int#|translation" (unary (_.do "floor" (list) {.#None}))) + (dictionary.has "f64_encoded#|translation" (unary (_.do "to_s" (list) {.#None}))) + (dictionary.has "f64_decoded#|translation" (unary //runtime.f64//decode)))) (def (text//char [subjectO paramO]) (Binary Expression) @@ -189,18 +206,31 @@ (Trinary Expression) (//runtime.text//index textO partO startO)) -(def text_procs - Bundle - (<| (/.prefix "text") - (|> /.empty - (/.install "=" (binary (product.uncurried _.=))) - (/.install "<" (binary (product.uncurried _.<))) - (/.install "concat" (binary (product.uncurried (function.flipped _.+)))) - (/.install "index" (trinary text//index)) - (/.install "size" (unary (_.the "length"))) - (/.install "char" (binary (product.uncurried //runtime.text//char))) - (/.install "clip" (trinary text//clip)) - ))) +(def text//composite + (Variadic Expression) + (|>> (|.when + (list) + (_.string "") + + (list single) + single + + (list left right) + (|> left (_.+ right)) + + parts + (list#mix _.bit_shl (_.string "") parts)))) + +(def with_text_extensions + (-> Bundle Bundle) + (|>> (dictionary.has "text_=#|translation" (binary (product.uncurried _.=))) + (dictionary.has "text_<#|translation" (binary (product.uncurried _.<))) + (dictionary.has "text_composite#|translation" (variadic ..text//composite)) + (dictionary.has "text_index#|translation" (trinary text//index)) + (dictionary.has "text_size#|translation" (unary (_.the "length"))) + (dictionary.has "text_char#|translation" (binary (product.uncurried //runtime.text//char))) + (dictionary.has "text_clip#|translation" (trinary text//clip)) + )) (def (io//log! messageG) (Unary Expression) @@ -211,20 +241,19 @@ (Unary Expression) _.raise) -(def io_procs - Bundle - (<| (/.prefix "io") - (|> /.empty - (/.install "log" (unary ..io//log!)) - (/.install "error" (unary ..io//error!)) - ))) +(def with_io_extensions + (-> Bundle Bundle) + (|>> (dictionary.has "log!#|translation" (unary ..io//log!)) + (dictionary.has "error#|translation" (unary ..io//error!)) + )) (def .public bundle Bundle - (<| (/.prefix "lux") - (|> lux_procs - (dictionary.composite ..i64_procs) - (dictionary.composite ..f64_procs) - (dictionary.composite ..text_procs) - (dictionary.composite ..io_procs) - ))) + (|> extension.empty + with_basic_extensions + with_i64_extensions + with_int_extensions + with_f64_extensions + with_text_extensions + with_io_extensions + )) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/ruby/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/ruby/host.lux index b4a2ef91d..aedb08fb0 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/ruby/host.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/ruby/host.lux @@ -4,7 +4,7 @@ [abstract ["[0]" monad (.only do)]] [control - ["<>" parser] + ["?" parser] ["[0]" function]] [data [collection @@ -15,24 +15,22 @@ [meta [target ["_" ruby (.only Var Expression)]]]]] - ["[0]" // - ["[1][0]" common (.only custom)] - ["//[1]" /// - ["/" bundle] - ["/[1]" // - ["[0]" extension] - [translation - [extension (.only Nullary Unary Binary Trinary - nullary unary binary trinary)] - ["[0]" reference] - ["//" ruby - ["[1][0]" runtime (.only Operation Phase Handler Bundle - with_vars)]]] - ["/[1]" // - [synthesis - ["<s>" \\parser (.only Parser)]] - ["//[1]" /// - ["[1][0]" phase]]]]]]) + [// + [common (.only custom)] + [//// + ["[0]" extension] + [translation + [extension (.only Nullary Unary Binary Trinary + nullary unary binary trinary)] + ["[0]" reference] + [ruby + ["[0]" runtime (.only Operation Phase Handler Bundle + with_vars)]]] + [// + ["[0]" synthesis + ["?[1]" \\parser (.only Parser)]] + [/// + ["[0]" phase]]]]]) (def (array::new [size]) (Unary Expression) @@ -48,38 +46,36 @@ (def (array::write [indexG valueG arrayG]) (Trinary Expression) - (//runtime.array//write indexG valueG arrayG)) + (runtime.array//write indexG valueG arrayG)) (def (array::delete [indexG arrayG]) (Binary Expression) - (//runtime.array//write indexG _.nil arrayG)) + (runtime.array//write indexG _.nil arrayG)) -(def array - Bundle - (<| (/.prefix "array") - (|> /.empty - (/.install "new" (unary array::new)) - (/.install "length" (unary array::length)) - (/.install "read" (binary array::read)) - (/.install "write" (trinary array::write)) - (/.install "delete" (binary array::delete)) - ))) +(def with_array_extensions + (-> Bundle Bundle) + (|>> (dictionary.has "ruby_array_new#|translation" (unary array::new)) + (dictionary.has "ruby_array_length#|translation" (unary array::length)) + (dictionary.has "ruby_array_read#|translation" (binary array::read)) + (dictionary.has "ruby_array_write#|translation" (trinary array::write)) + (dictionary.has "ruby_array_delete#|translation" (binary array::delete)) + )) (def object::get Handler (custom - [(all <>.and <s>.text <s>.any) - (function (_ extension phase archive [fieldS objectS]) - (do ////////phase.monad + [(all ?.and ?synthesis.text ?synthesis.any) + (function (_ phase archive [fieldS objectS]) + (do phase.monad [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) (def object::do Handler (custom - [(all <>.and <s>.text <s>.any (<>.some <s>.any)) - (function (_ extension phase archive [methodS objectS inputsS]) - (do [! ////////phase.monad] + [(all ?.and ?synthesis.text ?synthesis.any (?.some ?synthesis.any)) + (function (_ phase archive [methodS objectS inputsS]) + (do [! phase.monad] [objectG (phase archive objectS) inputsG (monad.each ! (phase archive) inputsS)] (in (_.do methodS inputsG {.#None} objectG))))])) @@ -91,47 +87,44 @@ [object::nil object::nil? _.nil] ) -(def object - Bundle - (<| (/.prefix "object") - (|> /.empty - (/.install "get" object::get) - (/.install "do" object::do) - (/.install "nil" (nullary object::nil)) - (/.install "nil?" (unary object::nil?)) - ))) +(def with_object_extensions + (-> Bundle Bundle) + (|>> (dictionary.has "ruby_object_get#|translation" object::get) + (dictionary.has "ruby_object_do#|translation" object::do) + (dictionary.has "ruby_object_nil#|translation" (nullary object::nil)) + (dictionary.has "ruby_object_nil?#|translation" (unary object::nil?)) + )) (def ruby::constant (custom - [<s>.text - (function (_ extension phase archive name) - (at ////////phase.monad in (is _.CVar (_.manual name))))])) + [?synthesis.text + (function (_ phase archive name) + (at phase.monad in (is _.CVar (_.manual name))))])) (def ruby::apply (custom - [(all <>.and <s>.any (<>.some <s>.any)) - (function (_ extension phase archive [abstractionS inputsS]) - (do [! ////////phase.monad] + [(all ?.and ?synthesis.any (?.some ?synthesis.any)) + (function (_ phase archive [abstractionS inputsS]) + (do [! phase.monad] [abstractionG (phase archive abstractionS) inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG {.#None} abstractionG))))])) (def ruby::import (custom - [<s>.text - (function (_ extension phase archive module) - (at ////////phase.monad in + [?synthesis.text + (function (_ phase archive module) + (at phase.monad in (_.require/1 (_.string module))))])) (def .public bundle Bundle - (<| (/.prefix "ruby") - (|> /.empty - (dictionary.composite ..array) - (dictionary.composite ..object) - - (/.install "constant" ruby::constant) - (/.install "apply" ruby::apply) - (/.install "import" ruby::import) - (/.install "script universe" (nullary (function.constant (_.bool reference.universe)))) - ))) + (|> extension.empty + with_array_extensions + with_object_extensions + + (dictionary.has "ruby_constant#|translation" ruby::constant) + (dictionary.has "ruby_apply#|translation" ruby::apply) + (dictionary.has "ruby_import#|translation" ruby::import) + (dictionary.has "ruby_script_universe#|translation" (nullary (function.constant (_.bool reference.universe)))) + )) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/reference.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/reference.lux index 325ec417a..3760acc35 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/reference.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/reference.lux @@ -26,7 +26,7 @@ @.ruby ... Cannot make all definitions be local variables because of limitations with JRuby. - (not ("ruby script universe")) + (not (.ruby_script_universe#)) @.php ... Cannot make all definitions be local variables because of limitations with PHP itself. diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby.lux index 0be9676bc..427411877 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby.lux @@ -35,46 +35,46 @@ (exception.def .public cannot_recur_as_an_expression) -(def (expression archive synthesis) - Phase - (when synthesis - (^.with_template [<tag> <translator>] - [(<tag> value) - (//////phase#in (<translator> value))]) - ([////synthesis.bit /primitive.bit] - [////synthesis.i64 /primitive.i64] - [////synthesis.f64 /primitive.f64] - [////synthesis.text /primitive.text]) +(def .public (expression extender lux) + (-> ///extension.Extender Lux + Phase) + (function (expression archive synthesis) + (when synthesis + (^.with_template [<tag> <translator>] + [(<tag> @ value) + (//////phase#in (<translator> value))]) + ([////synthesis.bit /primitive.bit] + [////synthesis.i64 /primitive.i64] + [////synthesis.f64 /primitive.f64] + [////synthesis.text /primitive.text]) - (^.with_template [<tag> <translator>] - [(<tag> value) - (<translator> expression archive value)]) - ([////synthesis.variant /structure.variant] - [////synthesis.tuple /structure.tuple] - - [////synthesis.branch/exec /when.exec] - [////synthesis.branch/let /when.let] - [////synthesis.branch/if /when.if] - [////synthesis.branch/get /when.get] - - [////synthesis.function/apply /function.apply]) + (^.with_template [<tag> <translator>] + [(<tag> @ value) + (<translator> expression archive value)]) + ([////synthesis.variant /structure.variant] + [////synthesis.tuple /structure.tuple] + + [////synthesis.branch/exec /when.exec] + [////synthesis.branch/let /when.let] + [////synthesis.branch/if /when.if] + [////synthesis.branch/get /when.get] + + [////synthesis.function/apply /function.apply]) - (^.with_template [<tag> <translator>] - [(<tag> value) - (<translator> ///extension/common.statement expression archive value)]) - ([////synthesis.branch/when /when.when] - [////synthesis.loop/scope /loop.scope] - [////synthesis.function/abstraction /function.function]) + (^.with_template [<tag> <translator>] + [(<tag> @ value) + (<translator> ///extension/common.statement expression archive value)]) + ([////synthesis.branch/when /when.when] + [////synthesis.loop/scope /loop.scope] + [////synthesis.function/abstraction /function.function]) - (////synthesis.loop/again _) - (//////phase.except ..cannot_recur_as_an_expression []) + (////synthesis.loop/again @ _) + (//////phase.except ..cannot_recur_as_an_expression []) - {////synthesis.#Reference value} - (//reference.reference /reference.system archive value) + [@ {////synthesis.#Reference value}] + (//reference.reference /reference.system archive value) - {////synthesis.#Extension extension} - (///extension.apply archive expression extension))) - -(def .public translate - Phase - ..expression) + [@ {////synthesis.#Extension [name parameters]}] + (///extension.application extender lux expression archive .Translation false name parameters + (|>>) + (function (_ _) {.#None}))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/function.lux index 0871e05bb..0d48bb642 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/function.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/function.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except function) + [lux (.except Analysis Synthesis function) [abstract ["[0]" monad (.only do)]] [data diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/loop.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/loop.lux index 045789f91..49c76bdee 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/loop.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/loop.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except Scope symbol) + [lux (.except Scope Synthesis symbol) [abstract ["[0]" monad (.only do)]] [data diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/structure.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/structure.lux index 2da3e556a..748d4be1d 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/structure.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/structure.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except Variant Tuple) + [lux (.except Variant Tuple Synthesis) [abstract ["[0]" monad (.only do)]] [meta diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/when.lux index ab9c20baa..dfb8254f6 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/when.lux @@ -1,6 +1,6 @@ (.require [library - [lux (.except when exec let if symbol) + [lux (.except Synthesis when exec let if symbol) [abstract ["[0]" monad (.only do)]] [data diff --git a/stdlib/source/library/lux/world/money/currency.lux b/stdlib/source/library/lux/world/money/currency.lux new file mode 100644 index 000000000..93b92be1f --- /dev/null +++ b/stdlib/source/library/lux/world/money/currency.lux @@ -0,0 +1,243 @@ +... https://en.wikipedia.org/wiki/Currency +(.require + [library + [lux (.except type all try) + [meta + [type + ["[0]" nominal]]]]]) + +(nominal.def .public (Currency of) + (Record + [#alphabetic_code Text + #numeric_code Nat + #decimals Nat]) + + (def .public (currency [alphabetic_code numeric_code decimals]) + (Ex (_ of) + (-> [Text Nat Nat] + (Currency of))) + (nominal.abstraction + [#alphabetic_code alphabetic_code + #numeric_code numeric_code + #decimals decimals])) + + (with_template [<name> <slot> <type>] + [(def .public <name> + (All (_ of) + (-> (Currency of) + <type>)) + (|>> nominal.representation + (the <slot>)))] + + [alphabetic_code #alphabetic_code Text] + [numeric_code #numeric_code Nat] + [decimals #decimals Nat] + ) + ) + +(def .public type + (template (_ <currency>) + ... TODO: Switch to the cleaner approach ASAP. + [(when (type_of <currency>) + {.#Apply it currency?} + (if (same? Currency currency?) + it + (undefined)) + + _ + (undefined))])) + +... https://en.wikipedia.org/wiki/ISO_4217 +(with_template [<short> <type> <alphabetic_code> <numeric_code> <decimals> <long>] + [(def .public <short> + (..currency [<alphabetic_code> <numeric_code> <decimals>])) + + (def .public <type> + Type + (let [[module short] (symbol .._)] + {.#Named [module <alphabetic_code>] + (..type <short>)})) + + (def .public <long> + (Currency <type>) + <short>)] + + [aed AED "AED" 784 2 united_arab_emirates_dirham] + [afn AFN "AFN" 971 2 afghan_afghani] + [all ALL "ALL" 008 2 albanian_lek] + [amd AMD "AMD" 051 2 armenian_dram] + [ang ANG "ANG" 532 2 netherlands_antillean_guilder] + [aoa AOA "AOA" 973 2 angolan_kwanza] + [ars ARS "ARS" 032 2 argentine_peso] + [aud AUD "AUD" 036 2 australian_dollar] + [awg AWG "AWG" 533 2 aruban_florin] + [azn AZN "AZN" 944 2 azerbaijani_manat] + [bam BAM "BAM" 977 2 bosnia_and_herzegovina_convertible_mark] + + [bbd BBD "BBD" 052 2 barbados_dollar] + [bdt BDT "BDT" 050 2 bangladeshi_taka] + [bgn BGN "BGN" 975 2 bulgarian_lev] + [bhd BHD "BHD" 048 3 bahraini_dinar] + [bif BIF "BIF" 108 0 burundian_franc] + [bmd BMD "BMD" 060 2 bermudian_dollar] + [bnd BND "BND" 096 2 brunei_dollar] + [bob BOB "BOB" 068 2 boliviano] + [brl BRL "BRL" 986 2 brazilian_real] + [bsd BSD "BSD" 044 2 bahamian_dollar] + [btn BTN "BTN" 064 2 bhutanese_ngultrum] + [bwp BWP "BWP" 072 2 botswana_pula] + [byn BYN "BYN" 933 2 belarusian_ruble] + [bzd BZD "BZD" 084 2 belize_dollar] + + [cad CAD "CAD" 124 2 canadian_dollar] + [cdf CDF "CDF" 976 2 congolese_franc] + [chf CHF "CHF" 756 2 swiss_franc] + [clp CLP "CLP" 152 0 chilean_peso] + [cop COP "COP" 170 2 colombian_peso] + [crc CRC "CRC" 188 2 costa_rican_colon] + [cuc CUC "CUC" 931 2 cuban_convertible_peso] + [cup CUP "CUP" 192 2 cuban_peso] + [cve CVE "CVE" 132 2 cape_verdean_escudo] + [czk CZK "CZK" 203 2 czech_koruna] + + [djf DJF "DJF" 262 0 djiboutian_franc] + [dkk DKK "DKK" 208 2 danish_krone] + [dop DOP "DOP" 214 2 dominican_peso] + [dzd DZD "DZD" 012 2 algerian_dinar] + + [egp EGP "EGP" 818 2 egyptian_pound] + [ern ERN "ERN" 232 2 eritrean_nakfa] + [etb ETB "ETB" 230 2 ethiopian_birr] + [eur EUR "EUR" 978 2 euro] + + [fjd FJD "FJD" 242 2 fiji_dollar] + [fkp FKP "FKP" 238 2 falkland_islands_pound] + + [gbp GBP "GBP" 826 2 pound_sterling] + [gel GEL "GEL" 981 2 georgian_lari] + [ghs GHS "GHS" 936 2 ghanaian_cedi] + [gip GIP "GIP" 292 2 gibraltar_pound] + [gmd GMD "GMD" 270 2 gambian_dalasi] + [gnf GNF "GNF" 324 0 guinean_franc] + [gtq GTQ "GTQ" 320 2 guatemalan_quetzal] + [gyd GYD "GYD" 328 2 guyanese_dollar] + + [hkd HKD "HKD" 344 2 hong_kong_dollar] + [hnl HNL "HNL" 340 2 honduran_lempira] + [hrk HRK "HRK" 191 2 croatian_kuna] + [htg HTG "HTG" 332 2 haitian_gourde] + [huf HUF "HUF" 348 2 hungarian_forint] + + [idr IDR "IDR" 360 2 indonesian_rupiah] + [ils ILS "ILS" 376 2 israeli_new_shekel] + [inr INR "INR" 356 2 indian_rupee] + [iqd IQD "IQD" 368 3 iraqi_dinar] + [irr IRR "IRR" 364 2 iranian_rial] + [isk ISK "ISK" 352 0 icelandic_krona] + + [jmd JMD "JMD" 388 2 jamaican_dollar] + [jod JOD "JOD" 400 3 jordanian_dinar] + [jpy JPY "JPY" 392 0 japanese_yen] + + [kes KES "KES" 404 2 kenyan_shilling] + [kgs KGS "KGS" 417 2 kyrgyzstani_som] + [khr KHR "KHR" 116 2 cambodian_riel] + [kmf KMF "KMF" 174 0 comoro_franc] + [kpw KPW "KPW" 408 2 north_korean_won] + [krw KRW "KRW" 410 0 south_korean_won] + [kwd KWD "KWD" 414 3 kuwaiti_dinar] + [kyd KYD "KYD" 136 2 cayman_islands_dollar] + [kzt KZT "KZT" 398 2 kazakhstani_tenge] + + [lak LAK "LAK" 418 2 lao_kip] + [lbp LBP "LBP" 422 2 lebanese_pound] + [lkr LKR "LKR" 144 2 sri_lankan_rupee] + [lrd LRD "LRD" 430 2 liberian_dollar] + [lsl LSL "LSL" 426 2 lesotho_loti] + [lyd LYD "LYD" 434 3 libyan_dinar] + + [mad MAD "MAD" 504 2 moroccan_dirham] + [mdl MDL "MDL" 498 2 moldovan_leu] + [mga MGA "MGA" 969 2 malagasy_ariary] + [mkd MKD "MKD" 807 2 macedonian_denar] + [mmk MMK "MMK" 104 2 myanmar_kyat] + [mnt MNT "MNT" 496 2 mongolian_togrog] + [mop MOP "MOP" 446 2 macanese_pataca] + [mru MRU "MRU" 929 2 mauritanian_ouguiya] + [mur MUR "MUR" 480 2 mauritian_rupee] + [mvr MVR "MVR" 462 2 maldivian_rufiyaa] + [mwk MWK "MWK" 454 2 malawian_kwacha] + [mxn MXN "MXN" 484 2 mexican_peso] + [myr MYR "MYR" 458 2 malaysian_ringgit] + [mzn MZN "MZN" 943 2 mozambican_metical] + + [nad NAD "NAD" 516 2 namibian_dollar] + [ngn NGN "NGN" 566 2 nigerian_naira] + [nio NIO "NIO" 558 2 nicaraguan_cordoba] + [nok NOK "NOK" 578 2 norwegian_krone] + [npr NPR "NPR" 524 2 nepalese_rupee] + [nzd NZD "NZD" 554 2 new_zealand_dollar] + + [omr OMR "OMR" 512 3 omani_rial] + + [pab PAB "PAB" 590 2 panamanian_balboa] + [pen PEN "PEN" 604 2 peruvian_sol] + [pgk PGK "PGK" 598 2 papua_new_guinean_kina] + [php PHP "PHP" 608 2 philippine_peso] + [pkr PKR "PKR" 586 2 pakistani_rupee] + [pln PLN "PLN" 985 2 polish_ztoty] + [pyg PYG "PYG" 600 0 paraguayan_guarani] + + [qar QAR "QAR" 634 2 qatari_riyal] + + [ron RON "RON" 946 2 romanian_leu] + [rsd RSD "RSD" 941 2 serbian_dinar] + [cny CNY "CNY" 156 2 renminbi] + [rub RUB "RUB" 643 2 russian_ruble] + [rwf RWF "RWF" 646 0 rwandan_franc] + + [sar SAR "SAR" 682 2 saudi_riyal] + [sbd SBD "SBD" 090 2 solomon_islands_dollar] + [scr SCR "SCR" 690 2 seychelles_rupee] + [sdg SDG "SDG" 938 2 sudanese_pound] + [sek SEK "SEK" 752 2 swedish_krona] + [sgd SGD "SGD" 702 2 singapore_dollar] + [shp SHP "SHP" 654 2 saint_helena_pound] + [sos SOS "SOS" 706 2 somali_shilling] + [srd SRD "SRD" 968 2 surinamese_dollar] + [ssp SSP "SSP" 728 2 south_sudanese_pound] + [stn STN "STN" 930 2 sao_tome_and_principe_dobra] + [svc SVC "SVC" 222 2 salvadoran_colon] + [syp SYP "SYP" 760 2 syrian_pound] + [szl SZL "SZL" 748 2 swazi_lilangeni] + + [thb THB "THB" 764 2 thai_baht] + [tjs TJS "TJS" 972 2 tajikistani_somoni] + [tmt TMT "TMT" 934 2 turkmenistan_manat] + [tnd TND "TND" 788 3 tunisian_dinar] + [top TOP "TOP" 776 2 tongan_pa'anga] + [try TRY "TRY" 949 2 turkish_lira] + [ttd TTD "TTD" 780 2 trinidad_and_tobago_dollar] + [twd TWD "TWD" 901 2 new_taiwan_dollar] + [tzs TZS "TZS" 834 2 tanzanian_shilling] + + [uah UAH "UAH" 980 2 ukrainian_hryvnia] + [ugx UGX "UGX" 800 0 ugandan_shilling] + [usd USD "USD" 840 2 united_states_dollar] + [uyu UYU "UYU" 858 2 uruguayan_peso] + [uzs UZS "UZS" 860 2 uzbekistan_sum] + [ves VES "VES" 928 2 venezuelan_sovereign_bolivar] + [vnd VND "VND" 704 0 vietnamese_dong] + [vuv VUV "VUV" 548 0 vanuatu_vatu] + [wst WST "WST" 882 2 samoan_tala] + + [xag XAG "XAG" 961 0 silver] + [xau XAU "XAU" 959 0 gold] + [xcd XCD "XCD" 951 2 east_caribbean_dollar] + [xpd XPD "XPD" 964 0 palladium] + [xpt XPT "XPT" 962 0 platinum] + + [zar ZAR "ZAR" 710 2 south_african_rand] + [zmw ZMW "ZMW" 967 2 zambian_kwacha] + [zwl ZWL "ZWL" 932 2 zimbabwean_dollar] + ) diff --git a/stdlib/source/library/lux/world/time/instant.lux b/stdlib/source/library/lux/world/time/instant.lux index 3c314db89..5f25e1d50 100644 --- a/stdlib/source/library/lux/world/time/instant.lux +++ b/stdlib/source/library/lux/world/time/instant.lux @@ -175,9 +175,9 @@ @.lua (|> (.lua_apply# (.lua_constant# "os.time") []) (as Int) (i.* +1,000)) - @.ruby (let [% ("ruby constant" "Time") - % ("ruby object do" "now" % [])] - (|> ("ruby object do" "to_f" % []) + @.ruby (let [% (.ruby_constant# "Time") + % (.ruby_object_do# "now" % [])] + (|> (.ruby_object_do# "to_f" % []) (as Frac) (f.* +1,000.0) .f64_int#)) |