From fe9a58dfcd5732ef0c5e5c4b7e85370cdc0db45a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 12 Dec 2022 03:47:35 -0400 Subject: Added trade session (OHLCV) abstraction. --- stdlib/source/library/lux/data/color.lux | 79 +----- stdlib/source/library/lux/data/color/cmyk.lux | 6 +- stdlib/source/library/lux/data/color/hsb.lux | 6 +- stdlib/source/library/lux/data/color/hsl.lux | 278 +++++++++++--------- stdlib/source/library/lux/data/color/rgb.lux | 182 ++++++------- stdlib/source/library/lux/data/color/terminal.lux | 6 +- stdlib/source/library/lux/ffi/export.js.lux | 2 +- stdlib/source/library/lux/ffi/export.lua.lux | 2 +- stdlib/source/library/lux/ffi/export.py.lux | 2 +- stdlib/source/library/lux/ffi/export.rb.lux | 2 +- stdlib/source/library/lux/math.lux | 2 +- .../library/lux/meta/compiler/default/init.lux | 54 ++-- .../library/lux/meta/compiler/default/platform.lux | 3 +- .../lux/meta/compiler/language/lux/analysis.lux | 3 +- .../compiler/language/lux/analysis/evaluation.lux | 2 +- .../compiler/language/lux/analysis/inference.lux | 3 +- .../meta/compiler/language/lux/analysis/macro.lux | 2 +- .../meta/compiler/language/lux/analysis/module.lux | 13 +- .../meta/compiler/language/lux/analysis/scope.lux | 7 +- .../meta/compiler/language/lux/analysis/type.lux | 2 +- .../lux/meta/compiler/language/lux/declaration.lux | 3 +- .../lux/meta/compiler/language/lux/phase.lux | 199 +++++++++++++++ .../meta/compiler/language/lux/phase/analysis.lux | 6 +- .../language/lux/phase/analysis/complex.lux | 57 ++--- .../language/lux/phase/analysis/function.lux | 23 +- .../language/lux/phase/analysis/reference.lux | 15 +- .../language/lux/phase/analysis/simple.lux | 16 +- .../compiler/language/lux/phase/analysis/when.lux | 47 ++-- .../compiler/language/lux/phase/declaration.lux | 2 +- .../meta/compiler/language/lux/phase/extension.lux | 7 +- .../language/lux/phase/extension/analysis/lux.lux | 2 +- .../lux/phase/extension/analysis/python.lux | 5 +- .../lux/phase/extension/declaration/lux.lux | 3 +- .../language/lux/phase/extension/synthesis/lux.lux | 5 +- .../lux/phase/extension/translation/jvm/common.lux | 2 +- .../lux/phase/extension/translation/jvm/host.lux | 50 ++-- .../phase/extension/translation/python/common.lux | 5 +- .../phase/extension/translation/python/host.lux | 5 +- .../meta/compiler/language/lux/phase/synthesis.lux | 2 +- .../language/lux/phase/synthesis/function.lux | 4 +- .../compiler/language/lux/phase/synthesis/loop.lux | 2 +- .../compiler/language/lux/phase/synthesis/when.lux | 56 ++-- .../language/lux/phase/translation/extension.lux | 11 +- .../language/lux/phase/translation/python.lux | 6 +- .../lux/phase/translation/python/function.lux | 10 +- .../language/lux/phase/translation/python/loop.lux | 8 +- .../lux/phase/translation/python/runtime.lux | 6 +- .../lux/phase/translation/python/structure.lux | 17 +- .../language/lux/phase/translation/python/when.lux | 58 ++--- .../language/lux/phase/translation/reference.lux | 14 +- .../lux/phase/translation/ruby/function.lux | 6 +- .../language/lux/phase/translation/ruby/loop.lux | 8 +- .../lux/phase/translation/ruby/runtime.lux | 6 +- .../lux/phase/translation/ruby/structure.lux | 17 +- .../language/lux/phase/translation/ruby/when.lux | 68 ++--- .../lux/meta/compiler/language/lux/synthesis.lux | 7 +- .../lux/meta/compiler/language/lux/translation.lux | 3 +- .../compiler/meta/cache/dependency/artifact.lux | 2 +- stdlib/source/library/lux/meta/compiler/phase.lux | 183 ------------- stdlib/source/library/lux/meta/extension.lux | 2 +- stdlib/source/library/lux/web/css/value.lux | 12 +- stdlib/source/library/lux/world/finance/money.lux | 151 +++++++++++ .../library/lux/world/finance/money/currency.lux | 283 +++++++++++++++++++++ .../library/lux/world/finance/trade/session.lux | 67 +++++ stdlib/source/library/lux/world/money.lux | 151 ----------- stdlib/source/library/lux/world/money/currency.lux | 283 --------------------- 66 files changed, 1284 insertions(+), 1267 deletions(-) create mode 100644 stdlib/source/library/lux/meta/compiler/language/lux/phase.lux delete mode 100644 stdlib/source/library/lux/meta/compiler/phase.lux create mode 100644 stdlib/source/library/lux/world/finance/money.lux create mode 100644 stdlib/source/library/lux/world/finance/money/currency.lux create mode 100644 stdlib/source/library/lux/world/finance/trade/session.lux delete mode 100644 stdlib/source/library/lux/world/money.lux delete mode 100644 stdlib/source/library/lux/world/money/currency.lux (limited to 'stdlib/source/library') diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index 2bfa5e5af..b65249c33 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -47,90 +47,19 @@ ... else it)) -(with_template [ ] - [(def .public ( ratio it) - (-> Frac Color Color) - (let [it (hsl.of_rgb (rgb it))] - (|> (hsl.hsl (hsl.hue it) - (|> it - hsl.saturation - (f.* (|> +1.0 ( (..ratio ratio)))) - (f.min +1.0)) - (hsl.luminance it)) - hsl.rgb - of_rgb)))] - - [f.+ saturated] - [f.- un_saturated] - ) - -(def .public (gray_scale color) - (-> Color Color) - (let [color (hsl.of_rgb (rgb color))] - (|> (hsl.hsl +0.0 - +0.0 - (hsl.luminance color)) - hsl.rgb - of_rgb))) - -(with_template [ <1> <2>] - [(`` (def .public ( color) - (-> Color [Color Color Color]) - (let [hsl (hsl.of_rgb (rgb color)) - hue (hsl.hue hsl) - saturation (hsl.saturation hsl) - luminance (hsl.luminance hsl)] - [color - (|> (hsl.hsl (|> hue (f.+ <1>) ..ratio) - saturation - luminance) - hsl.rgb - of_rgb) - (|> (hsl.hsl (|> hue (f.+ <2>) ..ratio) - saturation - luminance) - hsl.rgb - of_rgb)])))] - - [triad (|> +1.0 (f./ +3.0)) (|> +2.0 (f./ +3.0))] - [clash (|> +1.0 (f./ +4.0)) (|> +3.0 (f./ +4.0))] - [split_complement (|> +1.0 (f./ +5.0)) (|> +3.0 (f./ +5.0))] - ) - -(with_template [ <1> <2> <3>] - [(`` (def .public ( color) - (-> Color [Color Color Color Color]) - (let [it (hsl.of_rgb (..rgb color)) - hue (hsl.hue it) - saturation (hsl.saturation it) - luminance (hsl.luminance it) - of_hue (is (-> hsl.Value - Color) - (function (_ hue) - (|> (hsl.hsl hue saturation luminance) - hsl.rgb - ..of_rgb)))] - [color - (|> hue (f.+ <1>) ..ratio of_hue) - (|> hue (f.+ <2>) ..ratio of_hue) - (|> hue (f.+ <3>) ..ratio of_hue)])))] - - [square (|> +1.0 (f./ +4.0)) (|> +2.0 (f./ +4.0)) (|> +3.0 (f./ +4.0))] - [tetradic (|> +2.0 (f./ +12.0)) (|> +6.0 (f./ +12.0)) (|> +8.0 (f./ +12.0))] - ) - (type .public Spread Frac) +... https://en.wikipedia.org/wiki/Color_scheme (type .public Palette (-> Spread Nat Color (List Color))) (def .public (analogous spread variations it) Palette (let [it (hsl.of_rgb (..rgb it)) - hue (hsl.hue it) - saturation (hsl.saturation it) - luminance (hsl.luminance it) + hue (the hsl.#hue it) + saturation (the hsl.#saturation it) + luminance (the hsl.#luminance it) spread (..ratio spread)] (list#each (function (_ idx) (|> (hsl.hsl (|> idx ++ .int int.frac (f.* spread) (f.+ hue) ..ratio) diff --git a/stdlib/source/library/lux/data/color/cmyk.lux b/stdlib/source/library/lux/data/color/cmyk.lux index ae47d9604..bd0a9d298 100644 --- a/stdlib/source/library/lux/data/color/cmyk.lux +++ b/stdlib/source/library/lux/data/color/cmyk.lux @@ -78,9 +78,9 @@ (def .public (cmyk it) (-> RGB CMYK) - (let [red (..down (rgb.red it)) - green (..down (rgb.green it)) - blue (..down (rgb.blue it)) + (let [red (..down (the rgb.#red it)) + green (..down (the rgb.#green it)) + blue (..down (the rgb.#blue it)) key (opposite (all f.max red green blue)) f (if (f.< ..most key) (f./ (opposite key) diff --git a/stdlib/source/library/lux/data/color/hsb.lux b/stdlib/source/library/lux/data/color/hsb.lux index 5421c2dc3..ede1ffd08 100644 --- a/stdlib/source/library/lux/data/color/hsb.lux +++ b/stdlib/source/library/lux/data/color/hsb.lux @@ -97,9 +97,9 @@ (def .public (of_rgb it) (-> RGB HSB) - (let [red (..down (rgb.red it)) - green (..down (rgb.green it)) - blue (..down (rgb.blue it)) + (let [red (..down (the rgb.#red it)) + green (..down (the rgb.#green it)) + blue (..down (the rgb.#blue it)) max (all f.max red green blue) min (all f.min red green blue) diff --git a/stdlib/source/library/lux/data/color/hsl.lux b/stdlib/source/library/lux/data/color/hsl.lux index ce57f5210..835864b26 100644 --- a/stdlib/source/library/lux/data/color/hsl.lux +++ b/stdlib/source/library/lux/data/color/hsl.lux @@ -10,10 +10,7 @@ [math [number ["i" int] - ["f" frac]]] - [meta - [type - ["[0]" nominal]]]]] + ["f" frac]]]]] [// ["[0]" rgb (.only RGB)]]) @@ -56,117 +53,170 @@ (|>> (f.max ..least) (f.min ..most))) -(nominal.def .public HSL +(type .public HSL (Record [#hue Value #saturation Value - #luminance Value]) - - (def .public equivalence - (Equivalence HSL) - (implementation - (def (= left right) - (`` (and (,, (with_template [] - [(f.= (the (nominal.representation left)) - (the (nominal.representation right)))] - - [#hue] - [#saturation] - [#luminance] - ))))))) - - (with_template [ ] - [(def .public - (-> HSL - Value) - (|>> nominal.representation - (the )))] - - [hue #hue] - [saturation #saturation] - [luminance #luminance] - ) - - (def .public (hsl hue saturation luminance) - (-> Frac Frac Frac - HSL) - (nominal.abstraction - [#hue (..value hue) - #saturation (..value saturation) - #luminance (..value luminance)])) - - (def .public (of_rgb it) - (-> RGB - HSL) - (let [red (..down (rgb.red it)) - green (..down (rgb.green it)) - blue (..down (rgb.blue it)) - - max (all f.max red green blue) - min (all f.min red green blue) - luminance (|> (f.+ max min) (f./ +2.0))] - (nominal.abstraction - (if (f.= max min) - ... Achromatic - [#hue ..least - #saturation ..least - #luminance luminance] - ... Chromatic - (let [diff (|> max (f.- min)) - saturation (|> diff - (f./ (if (f.> +0.5 luminance) - (|> +2.0 (f.- max) (f.- min)) - (|> max (f.+ min))))) - hue' (cond (f.= red max) - (|> green (f.- blue) (f./ diff) - (f.+ (if (f.< blue green) +6.0 +0.0))) - - (f.= green max) - (|> blue (f.- red) (f./ diff) - (f.+ +2.0)) - - ... (f.= blue max) - (|> red (f.- green) (f./ diff) - (f.+ +4.0)))] - [#hue (|> hue' (f./ +6.0)) - #saturation saturation - #luminance luminance]))))) - - (def (hue_rgb p q t) - (-> Frac Frac Frac - Nat) - (let [t (cond (f.< +0.0 t) (f.+ +1.0 t) - (f.> +1.0 t) (f.- +1.0 t) - ... else - t) - f2/3 (f./ +3.0 +2.0)] - (..up (cond (f.< (f./ +6.0 +1.0) t) - (|> q (f.- p) (f.* +6.0) (f.* t) (f.+ p)) - - (f.< (f./ +2.0 +1.0) t) - q - - (f.< f2/3 t) - (|> q (f.- p) (f.* (|> f2/3 (f.- t))) (f.* +6.0) (f.+ p)) - - ... else - p)))) - - (def .public (rgb it) - (-> HSL - RGB) - (let [[hue saturation luminance] (nominal.representation it)] - (if (f.= ..least saturation) - ... Achromatic - (let [intensity (..up luminance)] - (rgb.rgb intensity intensity intensity)) - ... Chromatic - (let [q (if (f.< +0.5 luminance) - (|> saturation (f.+ +1.0) (f.* luminance)) - (|> luminance (f.+ saturation) (f.- (f.* saturation luminance)))) - p (|> luminance (f.* +2.0) (f.- q)) - third (|> +1.0 (f./ +3.0))] - (rgb.rgb (|> hue (f.+ third) (hue_rgb p q)) - (|> hue (hue_rgb p q)) - (|> hue (f.- third) (hue_rgb p q))))))) + #luminance Value])) + +(def .public equivalence + (Equivalence HSL) + (implementation + (def (= left right) + (`` (and (,, (with_template [] + [(f.= (the left) + (the right))] + + [#hue] + [#saturation] + [#luminance] + ))))))) + +(def .public (hsl hue saturation luminance) + (-> Frac Frac Frac + HSL) + [#hue (..value hue) + #saturation (..value saturation) + #luminance (..value luminance)]) + +(def .public (of_rgb it) + (-> RGB + HSL) + (let [red (..down (the rgb.#red it)) + green (..down (the rgb.#green it)) + blue (..down (the rgb.#blue it)) + + max (all f.max red green blue) + min (all f.min red green blue) + luminance (|> (f.+ max min) (f./ +2.0))] + (if (f.= max min) + ... Achromatic + [#hue ..least + #saturation ..least + #luminance luminance] + ... Chromatic + (let [diff (|> max (f.- min)) + saturation (|> diff + (f./ (if (f.> +0.5 luminance) + (|> +2.0 (f.- max) (f.- min)) + (|> max (f.+ min))))) + hue' (cond (f.= red max) + (|> green (f.- blue) (f./ diff) + (f.+ (if (f.< blue green) +6.0 +0.0))) + + (f.= green max) + (|> blue (f.- red) (f./ diff) + (f.+ +2.0)) + + ... (f.= blue max) + (|> red (f.- green) (f./ diff) + (f.+ +4.0)))] + [#hue (|> hue' (f./ +6.0)) + #saturation saturation + #luminance luminance])))) + +(def (hue_rgb p q t) + (-> Frac Frac Frac + Nat) + (let [t (cond (f.< +0.0 t) (f.+ +1.0 t) + (f.> +1.0 t) (f.- +1.0 t) + ... else + t) + f2/3 (f./ +3.0 +2.0)] + (..up (cond (f.< (f./ +6.0 +1.0) t) + (|> q (f.- p) (f.* +6.0) (f.* t) (f.+ p)) + + (f.< (f./ +2.0 +1.0) t) + q + + (f.< f2/3 t) + (|> q (f.- p) (f.* (|> f2/3 (f.- t))) (f.* +6.0) (f.+ p)) + + ... else + p)))) + +(def .public (rgb (open "/[0]")) + (-> HSL + RGB) + (if (f.= ..least /#saturation) + ... Achromatic + (let [intensity (..up /#luminance)] + (rgb.rgb intensity intensity intensity)) + ... Chromatic + (let [q (if (f.< +0.5 /#luminance) + (|> /#saturation (f.+ +1.0) (f.* /#luminance)) + (|> /#luminance (f.+ /#saturation) (f.- (f.* /#saturation /#luminance)))) + p (|> /#luminance (f.* +2.0) (f.- q)) + third (|> +1.0 (f./ +3.0))] + (rgb.rgb (|> /#hue (f.+ third) (hue_rgb p q)) + (|> /#hue (hue_rgb p q)) + (|> /#hue (f.- third) (hue_rgb p q)))))) + +(def (ratio it) + (-> Frac + Frac) + (cond (f.> +1.0 it) + (f.% +1.0 it) + + (f.< +0.0 it) + (|> it (f.% +1.0) (f.+ +1.0)) + + ... else + it)) + +(with_template [ ] + [(def .public ( ratio (open "/[0]")) + (-> Frac HSL + HSL) + (..hsl /#hue + (|> /#saturation + (f.* (|> +1.0 ( (..ratio ratio)))) + (f.min +1.0)) + /#luminance))] + + [f.+ saturated] + [f.- un_saturated] + ) + +(def .public gray_scale + (-> HSL + HSL) + (|>> (the #luminance) + (..hsl +0.0 + +0.0))) + +(with_template [ <1> <2>] + [(`` (def .public ( it) + (-> HSL + [HSL HSL HSL]) + (let [(open "/[0]") it] + [it + (..hsl (|> /#hue (f.+ <1>) ..ratio) + /#saturation + /#luminance) + (..hsl (|> /#hue (f.+ <2>) ..ratio) + /#saturation + /#luminance)])))] + + [triad (|> +1.0 (f./ +3.0)) (|> +2.0 (f./ +3.0))] + [clash (|> +1.0 (f./ +4.0)) (|> +3.0 (f./ +4.0))] + [split_complement (|> +1.0 (f./ +5.0)) (|> +3.0 (f./ +5.0))] + ) + +(with_template [ <1> <2> <3>] + [(`` (def .public ( it) + (-> HSL + [HSL HSL HSL HSL]) + (let [(open "/[0]") it + of_hue (is (-> Value + HSL) + (function (_ hue) + (..hsl hue /#saturation /#luminance)))] + [it + (|> /#hue (f.+ <1>) ..ratio of_hue) + (|> /#hue (f.+ <2>) ..ratio of_hue) + (|> /#hue (f.+ <3>) ..ratio of_hue)])))] + + [square (|> +1.0 (f./ +4.0)) (|> +2.0 (f./ +4.0)) (|> +3.0 (f./ +4.0))] + [tetradic (|> +2.0 (f./ +12.0)) (|> +6.0 (f./ +12.0)) (|> +8.0 (f./ +12.0))] ) diff --git a/stdlib/source/library/lux/data/color/rgb.lux b/stdlib/source/library/lux/data/color/rgb.lux index deb97365f..4dff2eb5d 100644 --- a/stdlib/source/library/lux/data/color/rgb.lux +++ b/stdlib/source/library/lux/data/color/rgb.lux @@ -5,7 +5,7 @@ [monad (.only do)] [monoid (.only Monoid)] [equivalence (.only Equivalence)] - ["[0]" hash (.only Hash)]] + [hash (.only Hash)]] [control [function [predicate (.only Predicate)]]] @@ -16,10 +16,7 @@ ["n" nat] ["i" int] ["f" frac] - ["[0]" i64]]] - [meta - [type - ["[0]" nominal]]]]]) + ["[0]" i64]]]]]) (def .public limit Nat @@ -48,104 +45,83 @@ (|>> (n.max ..least) (n.min ..most))) -(nominal.def .public RGB +(type .public RGB (Record [#red Value #green Value - #blue Value]) - - (def .public (rgb red green blue) - (-> Nat Nat Nat - RGB) - (nominal.abstraction - [#red (value red) - #green (value green) - #blue (value blue)])) - - (with_template [ ] - [(def .public - (-> RGB - Value) - (|>> nominal.representation - (the )))] - - [red #red] - [green #green] - [blue #blue] - ) - - (def .public hash - (Hash RGB) - (of hash.functor each - (|>> nominal.representation) - (all product.hash - n.hash - n.hash - n.hash - ))) - - (def .public equivalence - (Equivalence RGB) - (of ..hash equivalence)) - - (def (opposite_intensity value) - (-> Nat - Nat) - (|> ..most - (n.- value))) - - (def .public (complement it) - (-> RGB - RGB) - (nominal.abstraction - (`` [(,, (with_template [] - [ (|> it - nominal.representation - (the ) - opposite_intensity)] - - [#red] - [#green] - [#blue] - ))]))) - - (def .public black - RGB - (nominal.abstraction - [#red ..least - #green ..least - #blue ..least])) - - (def .public white - RGB - (nominal.abstraction - [#red ..most - #green ..most - #blue ..most])) - - (with_template [ ] - [(def .public - (Monoid RGB) - (implementation - (def identity - ) - - (def (composite left right) - (let [left ( left) - right ( right)] - (nominal.abstraction - (`` [(,, (with_template [] - [ ( (the (nominal.representation left)) - (the (nominal.representation right)))] - - [#red] - [#green] - [#blue] - ))]))))))] - - [addition ..black n.max |> |>] - [subtraction ..white n.min ..complement |>] - ) + #blue Value])) + +(def .public (rgb red green blue) + (-> Nat Nat Nat + RGB) + [#red (value red) + #green (value green) + #blue (value blue)]) + +(def .public hash + (Hash RGB) + (all product.hash + n.hash + n.hash + n.hash + )) + +(def .public equivalence + (Equivalence RGB) + (of ..hash equivalence)) + +(def (opposite_intensity value) + (-> Nat + Nat) + (|> ..most + (n.- value))) + +(def .public (complement it) + (-> RGB + RGB) + (`` [(,, (with_template [] + [ (|> it + (the ) + opposite_intensity)] + + [#red] + [#green] + [#blue] + ))])) + +(def .public black + RGB + [#red ..least + #green ..least + #blue ..least]) + +(def .public white + RGB + [#red ..most + #green ..most + #blue ..most]) + +(with_template [ ] + [(def .public + (Monoid RGB) + (implementation + (def identity + ) + + (def (composite left right) + (let [left ( left) + right ( right)] + (`` [(,, (with_template [] + [ ( (the left) + (the right))] + + [#red] + [#green] + [#blue] + ))])))))] + + [addition ..black n.max |> |>] + [subtraction ..white n.min ..complement |>] ) (def (ratio it) @@ -172,9 +148,9 @@ (f.+ (|> end .int i.frac (f.* dE))) f.int .nat)))] - (..rgb (interpolated' (..red end) (..red start)) - (interpolated' (..green end) (..green start)) - (interpolated' (..blue end) (..blue start))))) + (..rgb (interpolated' (the #red end) (the #red start)) + (interpolated' (the #green end) (the #green start)) + (interpolated' (the #blue end) (the #blue start))))) (with_template [ ] [(def .public diff --git a/stdlib/source/library/lux/data/color/terminal.lux b/stdlib/source/library/lux/data/color/terminal.lux index 64cf6bb64..06c23c6b3 100644 --- a/stdlib/source/library/lux/data/color/terminal.lux +++ b/stdlib/source/library/lux/data/color/terminal.lux @@ -90,9 +90,9 @@ (let [it (//.rgb it)] (|> [(%.format ..command - ";" (%.nat (rgb.red it)) - ";" (%.nat (rgb.green it)) - ";" (%.nat (rgb.blue it)) + ";" (%.nat (the rgb.#red it)) + ";" (%.nat (the rgb.#green it)) + ";" (%.nat (the rgb.#blue it)) "m") ] (nominal.abstraction Command))))] diff --git a/stdlib/source/library/lux/ffi/export.js.lux b/stdlib/source/library/lux/ffi/export.js.lux index bcd8117d7..ce8d8b478 100644 --- a/stdlib/source/library/lux/ffi/export.js.lux +++ b/stdlib/source/library/lux/ffi/export.js.lux @@ -21,13 +21,13 @@ [target ["/" js]] [compiler - ["[0]" phase] [meta [cache ["[0]" dependency ["[1]" artifact]]]] [language [lux + ["[0]" phase] ["[0]" translation] ["[0]" declaration] [analysis diff --git a/stdlib/source/library/lux/ffi/export.lua.lux b/stdlib/source/library/lux/ffi/export.lua.lux index b88cc91e9..8c0aa7b00 100644 --- a/stdlib/source/library/lux/ffi/export.lua.lux +++ b/stdlib/source/library/lux/ffi/export.lua.lux @@ -21,13 +21,13 @@ [target ["/" lua]] [compiler - ["[0]" phase] [meta [cache ["[0]" dependency ["[1]" artifact]]]] [language [lux + ["[0]" phase] ["[0]" translation] ["[0]" declaration] [analysis diff --git a/stdlib/source/library/lux/ffi/export.py.lux b/stdlib/source/library/lux/ffi/export.py.lux index 4f1b21b79..faf492f1e 100644 --- a/stdlib/source/library/lux/ffi/export.py.lux +++ b/stdlib/source/library/lux/ffi/export.py.lux @@ -21,13 +21,13 @@ [target ["/" python]] [compiler - ["[0]" phase] [meta [cache ["[0]" dependency ["[1]" artifact]]]] [language [lux + ["[0]" phase] ["[0]" translation] ["[0]" declaration] [analysis diff --git a/stdlib/source/library/lux/ffi/export.rb.lux b/stdlib/source/library/lux/ffi/export.rb.lux index 8f85a5f00..bd76976e7 100644 --- a/stdlib/source/library/lux/ffi/export.rb.lux +++ b/stdlib/source/library/lux/ffi/export.rb.lux @@ -23,12 +23,12 @@ [target ["/" ruby]] [compiler - ["[0]" phase] [meta [cache ["[0]" dependency ["[1]" artifact]]]] [language + ["[0]" phase] [lux ["[0]" translation] ["[0]" declaration] diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index a952076c2..de44e4d21 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -22,9 +22,9 @@ [type ["[0]" check]] [compiler - ["[0]" phase (.use "[1]#[0]" monad)] [language [lux + ["[0]" phase (.use "[1]#[0]" monad)] ["[0]" analysis (.only Analysis Operation Phase) ["[0]" type]]]] [meta diff --git a/stdlib/source/library/lux/meta/compiler/default/init.lux b/stdlib/source/library/lux/meta/compiler/default/init.lux index d4c342829..8c12039a6 100644 --- a/stdlib/source/library/lux/meta/compiler/default/init.lux +++ b/stdlib/source/library/lux/meta/compiler/default/init.lux @@ -24,9 +24,9 @@ ["[0]" file]]]] ["[0]" // ["/[1]" // (.only Instancer) - ["[1][0]" phase] [language [lux + ["[0]" phase] ["[1][0]" program (.only Program)] ["[1][0]" syntax (.only Aliases)] ["[1][0]" synthesis] @@ -102,7 +102,7 @@ (def (with_analysis_defaults bundle) (-> ///analysis.Bundle (Operation Any)) - (do [! ///phase.monad] + (do [! phase.monad] [_ (|> bundle dictionary.entries (monad.each ! @@ -114,7 +114,7 @@ (def (with_synthesis_defaults bundle) (-> ///synthesis.Bundle (Operation Any)) - (do [! ///phase.monad] + (do [! phase.monad] [_ (|> bundle dictionary.entries (monad.each ! @@ -127,7 +127,7 @@ (All (_ anchor expression declaration) (-> (///translation.Bundle anchor expression declaration) (///declaration.Operation anchor expression declaration Any))) - (do [! ///phase.monad] + (do [! phase.monad] [_ (|> bundle dictionary.entries (monad.each ! @@ -140,7 +140,7 @@ (All (_ anchor expression declaration) (-> (///declaration.Bundle anchor expression declaration) (///declaration.Operation anchor expression declaration Any))) - (do [! ///phase.monad] + (do [! phase.monad] [_ (|> bundle dictionary.entries (monad.each ! @@ -163,7 +163,7 @@ (///declaration.Operation anchor expression declaration Any))) (when module .prelude - (do ///phase.monad + (do phase.monad [_ (with_analysis_defaults analysis_bundle) _ (with_synthesis_defaults synthesis_bundle) _ (with_translation_defaults translation_bundle)] @@ -171,7 +171,7 @@ luxD.bundle))) _ - (with ///phase.monad + (with phase.monad (in [])))) (def (begin dependencies hash input all_extensions) @@ -180,14 +180,14 @@ (Extensions anchor expression declaration) (///declaration.Operation anchor expression declaration [Source (Payload declaration)]))) - (do ///phase.monad + (do phase.monad [.let [module (the ///.#module input)] _ (///declaration.set_current_module module) _ (///declaration.of_analysis (moduleA.create hash module)) _ (with_defaults module all_extensions)] (///declaration.of_analysis - (do [! ///phase.monad] + (do [! phase.monad] [_ (monad.each ! moduleA.import dependencies) .let [source (///analysis.source (the ///.#module input) (the ///.#code input))] _ (///analysis.set_source_code source)] @@ -198,7 +198,7 @@ (-> descriptor.Module (All (_ anchor expression declaration) (///declaration.Operation anchor expression declaration [.Module (Payload declaration)]))) - (do ///phase.monad + (do phase.monad [_ (///declaration.of_analysis (moduleA.set_compiled module)) analysis_module (<| (is (Operation .Module)) @@ -217,7 +217,7 @@ (-> (Extender anchor expression declaration) (///declaration.Operation anchor expression declaration (Payload declaration)))) - (do ///phase.monad + (do phase.monad [buffer (///declaration.of_translation ///translation.buffer) registry (///declaration.of_translation @@ -227,10 +227,10 @@ ... TODO: Inline ASAP (def (process_declaration wrapper archive extender expander pre_payoad code) (All (_ anchor expression declaration) - (-> ///phase.Wrapper Archive (Extender anchor expression declaration) Expander (Payload declaration) Code + (-> phase.Wrapper Archive (Extender anchor expression declaration) Expander (Payload declaration) Code (///declaration.Operation anchor expression declaration [Requirements (Payload declaration)]))) - (do ///phase.monad + (do phase.monad [.let [[pre_buffer pre_registry] pre_payoad] _ (///declaration.of_translation (///translation.set_buffer pre_buffer)) @@ -243,10 +243,10 @@ (def (iteration' wrapper archive extender expander reader source pre_payload) (All (_ anchor expression declaration) - (-> ///phase.Wrapper Archive (Extender anchor expression declaration) Expander Reader Source (Payload declaration) + (-> phase.Wrapper Archive (Extender anchor expression declaration) Expander Reader Source (Payload declaration) (///declaration.Operation anchor expression declaration [Source Requirements (Payload declaration)]))) - (do ///phase.monad + (do phase.monad [[source code] (///declaration.of_analysis (..read source reader)) [requirements post_payload] (process_declaration wrapper archive extender expander pre_payload code)] @@ -254,14 +254,14 @@ (def (iteration wrapper archive extender expander module source pre_payload aliases) (All (_ anchor expression declaration) - (-> ///phase.Wrapper Archive (Extender anchor expression declaration) Expander descriptor.Module Source (Payload declaration) Aliases + (-> phase.Wrapper Archive (Extender anchor expression declaration) Expander descriptor.Module Source (Payload declaration) Aliases (///declaration.Operation anchor expression declaration (Maybe [Source Requirements (Payload declaration)])))) - (do ///phase.monad + (do phase.monad [reader (///declaration.of_analysis (..reader module aliases source))] (function (_ state) - (when (///phase.result' state (..iteration' wrapper archive extender expander reader source pre_payload)) + (when (phase.result' state (..iteration' wrapper archive extender expander reader source pre_payload)) {try.#Success [state source&requirements&buffer]} {try.#Success [state {.#Some source&requirements&buffer}]} @@ -288,19 +288,19 @@ (Program expression declaration) (-> Archive Symbol (///translation.Operation expression)) descriptor.Module Text (///translation.Operation Any))) - (do ///phase.monad + (do phase.monad [ [@program _] (///translation.definition archive [program_module program_definition]) @self (///translation.learn [///program.name {.#None}] true (set.has @program (set.empty unit.hash))) |program| (global archive [program_module program_definition]) - @module (///phase.of_try (archive.id program_module archive))] + @module (phase.of_try (archive.id program_module archive))] (///translation.save! @self {.#None} (program [@module @self] |program|)))) (def .public (compiler program global wrapper extender expander prelude write_declaration program_module program_definition extensions) (All (_ ) (-> (Program expression declaration) (-> Archive Symbol (///translation.Operation expression)) - ///phase.Wrapper (Extender ) Expander descriptor.Module (-> declaration Binary) + phase.Wrapper (Extender ) Expander descriptor.Module (-> declaration Binary) descriptor.Module (Maybe Text) (Extensions ) (Instancer (///declaration.State ) .Module))) @@ -311,10 +311,10 @@ ///.#process (function (_ state archive) (do [! try.monad] [.let [hash (text#hash (the ///.#code input))] - [state [source buffer]] (<| (///phase.result' state) + [state [source buffer]] (<| (phase.result' state) (..begin dependencies hash input extensions)) .let [module (the ///.#module input)]] - (loop (again [iteration (<| (///phase.result' state) + (loop (again [iteration (<| (phase.result' state) (..iteration wrapper archive extender expander module source buffer ///syntax.no_aliases))]) (do ! [[state ?source&requirements&temporary_payload] iteration] @@ -322,8 +322,8 @@ {.#None} (do ! [[state [analysis_module [final_buffer final_registry]]] - (<| (///phase.result' state) - (do [! ///phase.monad] + (<| (phase.result' state) + (do [! phase.monad] [_ (if (text#= program_module module) (when program_definition {.#Some program_definition} @@ -355,8 +355,8 @@ (the ///declaration.#imports) (list#each product.left)) ///.#process (function (_ state archive) - (again (<| (///phase.result' state) - (do [! ///phase.monad] + (again (<| (phase.result' state) + (do [! phase.monad] [analysis_module (<| (is (Operation .Module)) ///declaration.of_analysis meta.current_module) diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux index 14d737c9f..a17939fe9 100644 --- a/stdlib/source/library/lux/meta/compiler/default/platform.lux +++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux @@ -37,7 +37,6 @@ ["[0]" // ["[1][0]" init] ["/[1]" // (.only) - ["[0]" phase (.only Phase) (.use "[1]#[0]" monad)] [language [lux [program (.only Program)] @@ -49,7 +48,7 @@ ["[1][0]" analysis (.only) [macro (.only Expander)] ["[0]A" module]] - [phase + ["[0]" phase (.only Phase) (.use "[1]#[0]" monad) ["[0]" extension]]]] [meta [import (.only Import)] diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux index 4adaf01c2..64e4418d0 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux @@ -36,12 +36,11 @@ ["[1][0]" complex (.only Tuple Variant Complex)] ["[1][0]" pattern (.only Pattern)] [// - [phase + ["[0]" phase (.only) ["[0]" extension (.only Extension)]] [/// [arity (.only Arity)] ["[0]" version (.only Version)] - ["[0]" phase] ["[0]" reference (.only Reference) ["[0]" variable (.only Register Variable)]] [meta diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux index 8ef79556a..f9487e936 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/evaluation.lux @@ -25,10 +25,10 @@ [phase ["[0]P" analysis] [// + ["[0]" phase] ["[0]" synthesis] ["[0]" translation] [/// - ["[0]" phase] [meta ["[0]" archive (.only Archive) ["[0]" module]]]]]]]]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/inference.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/inference.lux index c3f14a075..79de9721f 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/inference.lux @@ -25,10 +25,9 @@ ["/" // (.only Analysis Operation Phase) ["[1][0]" type] [// - [phase + ["[0]" phase (.use "[1]#[0]" monad) ["[0]" extension]] [/// - ["[0]" phase (.use "[1]#[0]" monad)] [meta [archive (.only Archive)]]]]]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/macro.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/macro.lux index 7abe0bc57..f9f715ca0 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/macro.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/macro.lux @@ -10,7 +10,7 @@ [data ["[0]" text ["%" \\format (.only format)]]]]] - [///// + [/// ["[0]" phase]]) (exception.def .public (expansion_failed [macro inputs error]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux index 8a47ab3b6..29dad85d1 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux @@ -15,9 +15,8 @@ ["[0]" list (.use "[1]#[0]" mix functor) ["[0]" property]]]]]] ["/" // (.only Operation) - ["//[1]" // - [/// - ["[1]" phase]]]]) + [// + ["[0]" phase]]]) (exception.def .public (unknown_module module) (Exception Text) @@ -57,7 +56,7 @@ (def .public (import module) (-> Text (Operation Any)) - (do ///.monad + (do phase.monad [self_name meta.current_module_name] (function (_ state) {try.#Success [(revised .#modules @@ -71,7 +70,7 @@ (def .public (alias alias module) (-> Text Text (Operation Any)) - (do ///.monad + (do phase.monad [self_name meta.current_module_name] (function (_ state) {try.#Success [(revised .#modules @@ -97,7 +96,7 @@ (def .public (define name exported?,definition) (-> Text [Bit Global] (Operation Any)) - (do ///.monad + (do phase.monad [self_name meta.current_module_name self meta.current_module] (function (_ state) @@ -137,7 +136,7 @@ (def .public (with hash name action) (All (_ a) (-> Nat Text (Operation a) (Operation [Module a]))) - (do ///.monad + (do phase.monad [_ (..create hash name) output (/.with_current_module name action) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux index bdfa5b776..e909fd3d2 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux @@ -14,10 +14,11 @@ ["[0]" list (.use "[1]#[0]" functor mix monoid) ["[0]" property]]]]]] ["/" // (.only Environment Operation Phase) - [//// + [// ["[0]" phase] - [reference - ["[0]" variable (.only Register Variable)]]]]) + [/// + [reference + ["[0]" variable (.only Register Variable)]]]]]) (type Local (Bindings Text [Type Register])) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/type.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/type.lux index f14a75e91..1ac2f8010 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/type.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/type.lux @@ -20,7 +20,7 @@ [type ["[0]" check (.only Check)]]]]] ["/" // (.only Operation) - [//// + [// ["[0]" phase]]]) (def .public (check action) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux b/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux index b0e7db3c2..6d33706fb 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux @@ -12,10 +12,9 @@ ["[0]" analysis] ["[0]" synthesis] ["[0]" translation] - [phase + ["[0]" phase (.only) ["[0]" extension]] [/// - ["[0]" phase] [meta [archive [module diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase.lux new file mode 100644 index 000000000..7192d1aff --- /dev/null +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase.lux @@ -0,0 +1,199 @@ +(.require + [library + [lux (.except except with try) + [abstract + [functor (.only Functor)] + [monad (.only Monad do)]] + [control + ["[0]" state] + ["[0]" try (.only Try) (.use "[1]#[0]" functor)] + ["[0]" exception (.only Exception)] + ["[0]" io]] + [data + ["[0]" product] + [text + ["%" \\format (.only format)]]] + [world + [time + ["[0]" instant] + ["[0]" duration]]]]] + [//// + [meta + [archive (.only Archive)]]]) + +(type .public (Operation state of) + (state.+State Try state of)) + +(def .public functor + (All (_ state) + (Functor (Operation state))) + (implementation + (def (each f it) + (function (_ state) + (when (it state) + {try.#Success [state' output]} + {try.#Success [state' (f output)]} + + {try.#Failure error} + {try.#Failure error}))))) + +(def .public monad + (All (_ state) + (Monad (Operation state))) + (implementation + (def functor ..functor) + + (def (in it) + (function (_ state) + {try.#Success [state it]})) + + (def (conjoint it) + (function (_ state) + (when (it state) + {try.#Success [state' it']} + (it' state') + + {try.#Failure error} + {try.#Failure error}))))) + +(type .public (Phase state input output) + (-> Archive input + (Operation state output))) + +(type .public Wrapper + (All (_ state input output) + (-> (Phase state input output) + Any))) + +(def .public (result' state operation) + (All (_ state of) + (-> state (Operation state of) + (Try [state of]))) + (operation state)) + +(def .public (result state operation) + (All (_ state of) + (-> state (Operation state of) + (Try of))) + (|> state + operation + (of try.monad each product.right))) + +(def .public state + (All (_ state) + (Operation state state)) + (function (_ state) + {try.#Success [state state]})) + +(def .public (with state) + (All (_ state) + (-> state + (Operation state Any))) + (function (_ _) + {try.#Success [state []]})) + +(def .public (sub [get set] operation) + (All (_ state state' of) + (-> [(-> state state') (-> state' state state)] + (Operation state' of) + (Operation state of))) + (function (_ state) + (do try.monad + [[state' output] (operation (get state))] + (in [(set state' state) output])))) + +(def .public failure + (-> Text + Operation) + (|>> {try.#Failure} (state.lifted try.monad))) + +(def .public (except exception parameters) + (All (_ of) + (-> (Exception of) of + Operation)) + (..failure (exception.error exception parameters))) + +(def .public (of_try error) + (All (_ state of) + (-> (Try of) + (Operation state of))) + (function (_ state) + (try#each (|>> [state]) error))) + +(def .public assertion + (template (_ exception message test) + [(if test + (of ..monad in []) + (..except exception message))])) + +(def .public (try it) + (All (_ state value) + (-> (Operation state value) + (Operation state (Try value)))) + (function (_ state) + (when (it state) + {try.#Success [state' it']} + {try.#Success [state' {try.#Success it'}]} + + {try.#Failure error} + {try.#Success [state {try.#Failure error}]}))) + +(def .public identity + (All (_ state of) + (Phase state of of)) + (function (_ archive input state) + {try.#Success [state input]})) + +(def .public (composite pre post) + (All (_ state/0 state/1 input middle output) + (-> (Phase state/0 input middle) + (Phase state/1 middle output) + (Phase [state/0 state/1] input output))) + (function (_ archive input [pre/state post/state]) + (do try.monad + [[pre/state' temp] (pre archive input pre/state) + [post/state' output] (post archive temp post/state)] + (in [[pre/state' post/state'] output])))) + +(def .public (read get) + (All (_ state of) + (-> (-> state of) + (Operation state of))) + (function (_ state) + {try.#Success [state (get state)]})) + +(def .public (update transform) + (All (_ state) + (-> (-> state state) + (Operation state Any))) + (function (_ state) + {try.#Success [(transform state) []]})) + +(def .public (localized get set transform) + (All (_ state state' of) + (-> (-> state state') (-> state' state state) (-> state' state') + (-> (Operation state of) + (Operation state of)))) + (function (_ operation) + (function (_ state) + (let [old (get state)] + (when (operation (set (transform old) state)) + {try.#Success [state' output]} + {try.#Success [(set old state') output]} + + failure + failure))))) + +(def .public (temporary transform) + (All (_ state of) + (-> (-> state state) + (-> (Operation state of) + (Operation state of)))) + (function (_ operation) + (function (_ state) + (when (operation (transform state)) + {try.#Success [state' output]} + {try.#Success [state output]} + + failure + failure)))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux index 7448e0212..eeaeb40a7 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis.lux @@ -28,14 +28,14 @@ ["[1][0]" reference] ["[1][0]" when] ["[1][0]" function] - ["/[1]" // + [// ["[0]" extension] - ["/[1]" // + [// + ["//" phase] ["/" analysis (.only Analysis Operation Phase Handler Extender) ["[1][0]" macro (.only Expander)] ["[1][0]" type]] [/// - ["//" phase] ["[0]" reference] [meta [archive (.only Archive)]]]]]]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux index 10f276346..27cadb489 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux @@ -25,16 +25,15 @@ ["[0]" check]]]]] ["[0]" // ["[1][0]" simple] - ["/[1]" // - [// - ["/" analysis (.only Analysis Operation Phase) - ["[1][0]" complex (.only Tag)] - ["[1][0]" type] - ["[1][0]" inference]] - [/// - ["[1]" phase (.use "[1]#[0]" monad)] - [meta - [archive (.only Archive)]]]]]]) + [/// + ["[0]" phase (.use "[1]#[0]" monad)] + ["/" analysis (.only Analysis Operation Phase) + ["[1][0]" complex (.only Tag)] + ["[1][0]" type] + ["[1][0]" inference]] + [/// + [meta + [archive (.only Archive)]]]]]) (exception.def .public (not_a_quantified_type type) (Exception Type) @@ -115,7 +114,7 @@ (-> Phase Nat Bit Phase) (let [tag (/complex.tag right? lefts)] (function (again valueC) - (do [! ///.monad] + (do [! phase.monad] [expectedT meta.expected_type expectedT' (/type.check (check.clean (list) expectedT)) @ meta.location] @@ -185,7 +184,7 @@ (def .public (variant analyse tag archive valueC) (-> Phase Symbol Phase) - (do [! ///.monad] + (do [! phase.monad] [tag (meta.normal tag) [lefts,right? variantT] (meta.tag tag) [lefts right?] (when lefts,right? @@ -209,7 +208,7 @@ (def (typed_product analyse expectedT archive members) (-> Phase Type Archive (List Code) (Operation Analysis)) - (<| (do [! ///.monad] + (<| (do [! phase.monad] [@ meta.location]) (of ! each (|>> (/.tuple @))) (is (Operation (List Analysis))) @@ -241,7 +240,7 @@ (def .public (product analyse archive membersC) (-> Phase Archive (List Code) (Operation Analysis)) - (do [! ///.monad] + (do [! phase.monad] [expectedT meta.expected_type] (/.with_exception ..cannot_analyse_tuple [expectedT membersC] (when expectedT @@ -319,21 +318,21 @@ (when input (list.partial [_ {.#Symbol ["" slotH]}] valueH tail) (if pattern_matching? - (///#in {.#None}) - (do ///.monad + (phase#in {.#None}) + (do phase.monad [slotH (meta.normal ["" slotH])] (again tail {.#Item [slotH valueH] output}))) (list.partial [_ {.#Symbol slotH}] valueH tail) - (do ///.monad + (do phase.monad [slotH (meta.normal slotH)] (again tail {.#Item [slotH valueH] output})) {.#End} - (///#in {.#Some output}) + (phase#in {.#Some output}) _ - (///#in {.#None})))) + (phase#in {.#None})))) (def (local_binding? name) (-> Text (Meta Bit)) @@ -397,7 +396,7 @@ ... Records, thus, get transformed into tuples by ordering the elements. (def (order' head_k original_record) (-> Symbol (List [Symbol Code]) (Operation (Maybe [Nat (List Code) Type]))) - (do [! ///.monad] + (do [! phase.monad] [record (<| meta.try (monad.each ! (function (_ [slot value]) (do ! @@ -408,10 +407,10 @@ {try.#Success record} (do ! [.let [record (sorted_record record)] - _ (///.assertion ..cannot_order_record [(` same_record?) original_record] - (same_record? record)) - _ (///.assertion ..cannot_order_record [(` complete_record?) original_record] - (complete_record? record))] + _ (phase.assertion ..cannot_order_record [(` same_record?) original_record] + (same_record? record)) + _ (phase.assertion ..cannot_order_record [(` complete_record?) original_record] + (complete_record? record))] (in (do maybe.monad [[[_ :record:] _] (list.head record)] (in [(list.size record) @@ -426,14 +425,14 @@ (when record ... empty_record = empty_tuple = unit/any = [] {.#End} - (///#in {.#Some [0 (list) .Any]}) + (phase#in {.#Some [0 (list) .Any]}) {.#Item [head_k head_v] _} (when head_k ["" head_k'] (if pattern_matching? - (///#in {.#None}) - (do ///.monad + (phase#in {.#None}) + (do phase.monad [local_binding? (..local_binding? head_k')] (if local_binding? (in {.#None}) @@ -452,7 +451,7 @@ (analyse archive singletonC) (list [_ {.#Symbol pseudo_slot}] singletonC) - (do [! ///.monad] + (do [! phase.monad] [head_k (meta.normal pseudo_slot) slot (meta.try (meta.slot head_k))] (when slot @@ -468,7 +467,7 @@ (..product analyse archive members))) _ - (do [! ///.monad] + (do [! phase.monad] [?members (..normal false members)] (when ?members {.#None} diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/function.lux index 06aef00dd..e0a0958a6 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/function.lux @@ -19,16 +19,15 @@ ["[0]" meta (.only) ["[0]" type (.only) ["[0]" check]]]]] - ["[0]" /// - [// - ["/" analysis (.only Analysis Operation Phase) - ["[1][0]" type] - ["[1][0]" inference] - ["[1][0]" scope]] - [/// - ["[1]" phase (.use "[1]#[0]" functor)] - [reference (.only) - [variable (.only)]]]]]) + [//// + ["[0]" phase (.use "[1]#[0]" functor)] + ["/" analysis (.only Analysis Operation Phase) + ["[1][0]" type] + ["[1][0]" inference] + ["[1][0]" scope]] + [/// + [reference (.only) + [variable (.only)]]]]) (exception.def .public (cannot_analyse [expected function argument body]) (Exception [Type Text Text Code]) @@ -51,7 +50,7 @@ (def .public (function analyse function_name arg_name archive body) (-> Phase Text Text Phase) - (do [! ///.monad] + (do [! phase.monad] [expectedT meta.expected_type] (loop (again [expectedT expectedT]) (/.with_exception ..cannot_analyse [expectedT function_name arg_name body] @@ -135,5 +134,5 @@ (def .public (apply analyse argsC+ :function: functionA archive functionC) (-> Phase (List Code) Type Analysis Phase) (|> (/inference.general archive analyse :function: argsC+) - (///#each (|>> product.right [functionA] /.reified)) + (phase#each (|>> product.right [functionA] /.reified)) (/.with_exception ..cannot_apply [:function: functionC argsC+]))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux index 733295658..a1331052a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux @@ -5,14 +5,13 @@ [monad (.only do)]] ["[0]" meta (.only) ["[0]" code]]]] - ["[0]" /// - [// - ["/" analysis (.only Analysis Operation Phase Extender) - ["[0]" scope]] - [/// - ["[0]" phase] - [meta - [archive (.only Archive)]]]]]) + [//// + ["[0]" phase] + ["/" analysis (.only Analysis Operation Phase Extender) + ["[0]" scope]] + [/// + [meta + [archive (.only Archive)]]]]) (def .public (reference extender analysis archive quoted_module it) (-> Extender Phase Archive Text Symbol (Operation Analysis)) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/simple.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/simple.lux index 914fe1fe7..ea315f7fc 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/simple.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/simple.lux @@ -4,19 +4,17 @@ ["[0]" meta] [abstract [monad (.only do)]]]] - ["[0]" /// - [// - ["/" analysis (.only Analysis Operation) - ["[1][0]" simple] - ["[1][0]" type]] - [/// - ["[1]" phase]]]]) + [//// + ["[0]" phase] + ["/" analysis (.only Analysis Operation) + ["[1][0]" simple] + ["[1][0]" type]]]) (with_template [ ] [(def .public ( value) (-> (Operation Analysis)) - (do ///.monad + (do phase.monad [_ (/type.inference ) @ meta.location] (in [@ {/.#Simple { value}}])))] @@ -31,7 +29,7 @@ (def .public unit (Operation Analysis) - (do ///.monad + (do phase.monad [_ (/type.inference .Any) @ meta.location] (in [@ {/.#Simple {/simple.#Unit}}]))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux index ef35059ba..101ff23c5 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux @@ -22,20 +22,17 @@ ["^" pattern]] ["[0]" type (.only) ["[0]" check (.only Check)]]]]] - ["[0]" / - ["/[1]" // - ["[1][0]" complex] - ["/[1]" // - [// - ["/" analysis (.only Analysis Operation Phase) - ["[1][0]" simple] - ["[1][0]" complex] - ["[1][0]" pattern (.only Pattern)] - ["[1][0]" type] - ["[1][0]" scope] - ["[1][0]" coverage (.only Coverage)]] - [/// - ["[1]" phase]]]]]]) + ["[0]" // + ["[1][0]" complex] + [/// + ["[0]" phase] + ["/" analysis (.only Analysis Operation Phase) + ["[1][0]" simple] + ["[1][0]" complex] + ["[1][0]" pattern (.only Pattern)] + ["[1][0]" type] + ["[1][0]" scope] + ["[1][0]" coverage (.only Coverage)]]]]) (exception.def .public (mismatch [type pattern]) (Exception [Type Code]) @@ -152,7 +149,7 @@ (def (simple_pattern_analysis type :input: location output next) (All (_ a) (-> Type Type Location Pattern (Operation a) (Operation [Pattern a]))) (/.with_location location - (do ///.monad + (do phase.monad [_ (/type.check (check.check :input: type)) outputA next] (in [output outputA])))) @@ -161,7 +158,7 @@ (All (_ a) (-> (-> Type Code (Operation a) (Operation [Pattern a])) Type (List Code) (Operation a) (Operation [Pattern a]))) - (do [! ///.monad] + (do [! phase.monad] [[@ex_var+ :input:'] (/type.check (..tuple :input:))] (.when :input:' {.#Product _} @@ -229,7 +226,7 @@ (.when pattern [location {.#Symbol ["" name]}] (/.with_location location - (do ///.monad + (do phase.monad [outputA (/scope.with_local [name :input:] next) idx /scope.next] @@ -251,7 +248,7 @@ [location {.#Tuple sub_patterns}] (/.with_location location - (do [! ///.monad] + (do [! phase.monad] [record (//complex.normal true sub_patterns) record_size,members,recordT (is (Operation (Maybe [Nat (List Code) Type])) (.when record @@ -285,7 +282,7 @@ [location {.#Variant (list.partial [_ {.#Nat lefts}] [_ {.#Bit right?}] values)}] (/.with_location location - (do ///.monad + (do phase.monad [[@ex_var+ :input:'] (/type.check (..tuple :input:))] (.when :input:' {.#Sum _} @@ -295,7 +292,7 @@ (.when (list.item idx flat_sum) (^.multi {.#Some caseT} (n.< size_sum idx)) - (do ///.monad + (do phase.monad [[testP nextA] (if (and (n.> size_sum size_sum) (n.= (-- size_sum) idx)) (pattern_analysis (type.variant (list.after (-- size_sum) flat_sum)) @@ -310,7 +307,7 @@ (/.except ..sum_has_no_case [idx :input:]))) {.#UnivQ _} - (do ///.monad + (do phase.monad [[ex_id exT] (/type.check check.existential) it (pattern_analysis (maybe.trusted (type.applied (list exT) :input:')) pattern @@ -323,7 +320,7 @@ [location {.#Variant (list.partial [_ {.#Symbol tag}] values)}] (/.with_location location - (do ///.monad + (do phase.monad [tag (meta.normal tag) [lefts,right? variantT] (meta.tag tag) [lefts right?] (in (.when lefts,right? @@ -343,7 +340,7 @@ (-> Phase (List [Code Code]) Phase) (.when branches {.#Item [patternH bodyH] branchesT} - (do [! ///.monad] + (do [! phase.monad] [[:input: inputA] (<| /type.inferring (analyse archive inputC)) outputH (pattern_analysis :input: patternH (analyse archive bodyH)) @@ -355,8 +352,8 @@ outputTC (monad.each ! (|>> product.left /coverage.coverage /.of_try) outputT) _ (.when (monad.mix try.monad /coverage.composite outputHC outputTC) {try.#Success coverage} - (///.assertion ..non_exhaustive [inputC branches coverage] - (/coverage.exhaustive? coverage)) + (phase.assertion ..non_exhaustive [inputC branches coverage] + (/coverage.exhaustive? coverage)) {try.#Failure error} (/.failure error)) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux index a47dc0e1d..b0c1283c0 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/declaration.lux @@ -18,12 +18,12 @@ ["[0]" extension] ["/[1]" // ["/" declaration (.only Operation Phase Handler Extender)] + ["[0]" phase (.use "[1]#[0]" monad)] ["[0]" analysis (.only) ["[0]" evaluation] ["[1]/[0]" macro (.only Expander)] ["[1]/[0]" type]] [/// - ["[0]" phase (.use "[1]#[0]" monad)] [reference (.only) [variable (.only)]] [meta diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension.lux index 0424495e0..5a8b93134 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension.lux @@ -21,10 +21,11 @@ ["[0]" symbol] [type (.only sharing) ["[0]" check]]]]] - [///// + [/// ["[0]" phase (.only Operation Phase) (.use "[1]#[0]" functor)] - [meta - [archive (.only Archive)]]]) + [/// + [meta + [archive (.only Archive)]]]]) (type .public (Extension of) (Record diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux index 3014365da..9157d3e66 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux @@ -30,13 +30,13 @@ ["[1]" lux]] ["/[1]" // [// + ["[0]" phase] ["[0]" analysis (.only Analysis Operation Phase Handler Bundle) [evaluation (.only Eval)] ["[0]A" type] ["[0]" scope]] [/// ["[0]" reference] - ["[0]" phase] [meta [archive (.only Archive)]]]]]]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux index eb457c03a..49721e9df 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/python.lux @@ -22,10 +22,9 @@ ["/" lux (.only custom)] ["/[1]" // (.only) [/// + ["[0]" phase] ["[0]" analysis (.only Analysis Operation Phase Handler Bundle) - ["[1]/[0]" type]] - [/// - ["[0]" phase]]]]]) + ["[1]/[0]" type]]]]]) (def array::new (-> Text Handler) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux index 3bda50cd1..e4d405e2c 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux @@ -43,13 +43,12 @@ ["[1][0]" synthesis (.only Synthesis)] ["[1][0]" translation] ["[1][0]" declaration (.only Import Requirements Phase Operation Handler Extender Bundle)] - [phase + ["[0]" phase (.only) [extension ["[0]E" analysis ["[1]" lux]]]] ["[1][0]" program (.only Program)] [/// - ["[0]" phase] [meta ["[0]" archive (.only Archive) ["[0]" artifact] diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/synthesis/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/synthesis/lux.lux index 5a57a54bd..8ab51ea4c 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/synthesis/lux.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/synthesis/lux.lux @@ -10,11 +10,10 @@ ["[0]" dictionary]]] [meta ["[0]" location] - ["[0]" symbol (.use "[1]#[0]" equivalence)] - [compiler - ["[0]" phase]]]]] + ["[0]" symbol (.use "[1]#[0]" equivalence)]]]] ["[0]" /// (.only) [/// + ["[0]" phase] ["[0]" synthesis (.only Synthesis Handler Bundle)]]]) (def .public synthesis diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux index b82acba31..654f1b008 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/common.lux @@ -36,10 +36,10 @@ ["[1][0]" function ["[1]" abstract]]]] [// + ["[0]" phase] ["[0]" synthesis (.only Synthesis %synthesis) ["<[1]>" \\parser (.only Parser)]] [/// - ["[0]" phase] [meta [archive (.only Archive)]]]]]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux index ded9a8bb4..fb9ee9327 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/jvm/host.lux @@ -64,13 +64,13 @@ [analysis ["/" jvm]]] ["/[1]" // + ["[0]" phase] ["[1][0]" translation] ["[0]" synthesis (.only Synthesis Path %synthesis) ["<[1]>" \\parser (.only Parser)]] [analysis (.only Environment) ["[0]" complex]] [/// - ["[1]" phase] ["[1][0]" reference (.only) ["[2][0]" variable (.only Variable Register)]] [meta @@ -383,7 +383,7 @@ (..custom [.any (function (_ translate archive arrayS) - (do //////.monad + (do phase.monad [arrayG (translate archive arrayS)] (in (all _.composite arrayG @@ -395,7 +395,7 @@ (..custom [(all <>.and ..object_array .any) (function (_ translate archive [elementJT arrayS]) - (do //////.monad + (do phase.monad [arrayG (translate archive arrayS)] (in (all _.composite arrayG @@ -407,7 +407,7 @@ (..custom [.any (function (_ translate archive [lengthS]) - (do //////.monad + (do phase.monad [lengthG (translate archive lengthS)] (in (all _.composite lengthG @@ -418,7 +418,7 @@ (..custom [(all <>.and ..object .any) (function (_ translate archive [objectJT lengthS]) - (do //////.monad + (do phase.monad [lengthG (translate archive lengthS)] (in (all _.composite lengthG @@ -429,7 +429,7 @@ (..custom [(all <>.and .any .any) (function (_ translate archive [idxS arrayS]) - (do //////.monad + (do phase.monad [arrayG (translate archive arrayS) idxG (translate archive idxS)] (in (all _.composite @@ -443,7 +443,7 @@ (..custom [(all <>.and ..object_array .any .any) (function (_ translate archive [elementJT idxS arrayS]) - (do //////.monad + (do phase.monad [arrayG (translate archive arrayS) idxG (translate archive idxS)] (in (all _.composite @@ -457,7 +457,7 @@ (..custom [(all <>.and .any .any .any) (function (_ translate archive [idxS valueS arrayS]) - (do //////.monad + (do phase.monad [arrayG (translate archive arrayS) idxG (translate archive idxS) valueG (translate archive valueS)] @@ -474,7 +474,7 @@ (..custom [(all <>.and ..object_array .any .any .any) (function (_ translate archive [elementJT idxS valueS arrayS]) - (do //////.monad + (do phase.monad [arrayG (translate archive arrayS) idxG (translate archive idxS) valueG (translate archive valueS)] @@ -576,7 +576,7 @@ (..custom [.text (function (_ translate archive [class]) - (do //////.monad + (do phase.monad [] (in (all _.composite (_.string class) @@ -587,7 +587,7 @@ (..custom [(all <>.and .text .any) (function (_ translate archive [class objectS]) - (do //////.monad + (do phase.monad [objectG (translate archive objectS)] (in (all _.composite objectG @@ -599,7 +599,7 @@ (..custom [(all <>.and .text .text .any) (function (_ translate archive [from to valueS]) - (do //////.monad + (do phase.monad [valueG (translate archive valueS)] (in (`` (cond (,, (with_template [ ] [(and (text#= (..reflection ) from) @@ -641,14 +641,14 @@ (..custom [(all <>.and .text .text ..value) (function (_ translate archive [class field :unboxed:]) - (of //////.monad in (_.getstatic (type.class class (list)) field :unboxed:)))])) + (of phase.monad in (_.getstatic (type.class class (list)) field :unboxed:)))])) (def put::static Handler (..custom [(all <>.and .text .text ..value .any) (function (_ translate archive [class field :unboxed: valueS]) - (do //////.monad + (do phase.monad [valueG (translate archive valueS)] (in (all _.composite valueG @@ -666,7 +666,7 @@ (..custom [(all <>.and .text .text ..value .any) (function (_ translate archive [class field :unboxed: objectS]) - (do //////.monad + (do phase.monad [objectG (translate archive objectS) .let [:class: (type.class class (list)) getG (_.getfield :class: field :unboxed:)]] @@ -680,7 +680,7 @@ (..custom [(all <>.and .text .text ..value .any .any) (function (_ translate archive [class field :unboxed: valueS objectS]) - (do //////.monad + (do phase.monad [valueG (translate archive valueS) objectG (translate archive objectS) .let [:class: (type.class class (list)) @@ -708,7 +708,7 @@ (def (translate_input translate archive [valueT valueS]) (-> Phase Archive Input (Operation (Typed (Bytecode Any)))) - (do //////.monad + (do phase.monad [valueG (translate archive valueS)] (when (type.primitive? valueT) {.#Right valueT} @@ -733,7 +733,7 @@ (..custom [(all <>.and ..class .text ..return (<>.some ..input)) (function (_ translate archive [class method outputT inputsTS]) - (do [! //////.monad] + (do [! phase.monad] [inputsTG (monad.each ! (translate_input translate archive) inputsTS)] (in (all _.composite (monad.each _.monad product.right inputsTG) @@ -746,7 +746,7 @@ (..custom [(all <>.and ..class .text ..return .any (<>.some ..input)) (function (_ translate archive [class method outputT objectS inputsTS]) - (do [! //////.monad] + (do [! phase.monad] [objectG (translate archive objectS) inputsTG (monad.each ! (translate_input translate archive) inputsTS)] (in (all _.composite @@ -768,7 +768,7 @@ (..custom [(all <>.and ..class (<>.some ..input)) (function (_ translate archive [class inputsTS]) - (do [! //////.monad] + (do [! phase.monad] [inputsTG (monad.each ! (translate_input translate archive) inputsTS)] (in (all _.composite (_.new class) @@ -1128,7 +1128,7 @@ (def (anonymous_instance translate archive class env inputsTI) (-> Phase Archive (Type category.Class) (Environment Synthesis) (List (Typed (Bytecode Any))) (Operation (Bytecode Any))) - (do [! //////.monad] + (do [! phase.monad] [captureG+ (monad.each ! (translate archive) env)] (in (all _.composite (_.new class) @@ -1188,7 +1188,7 @@ (def (anonymous_dependencies archive inputsTS overriden_methods) (-> Archive (List Input) (List [(Environment Synthesis) (/.Overriden_Method Synthesis)]) (Operation (Set unit.ID))) - (do [! //////.monad] + (do [! phase.monad] [all_input_dependencies (monad.each ! (|>> product.right (cache/artifact.dependencies archive)) inputsTS) all_closure_dependencies (|> overriden_methods (list#each product.left) @@ -1289,7 +1289,7 @@ (def (method_definition phase archive artifact_id method) (-> Phase Archive artifact.ID (/.Overriden_Method Synthesis) (Operation (Resource Method))) (let [[ownerT name strict_fp? annotations vars self_name arguments returnT exceptionsT bodyS] method] - (do //////.monad + (do phase.monad [bodyG (//////translation.with_context artifact_id (phase archive bodyS)) .let [argumentsT (list#each product.right arguments) @@ -1320,7 +1320,7 @@ super_interfaces inputsTS overriden_methods]) - (do [! //////.monad] + (do [! phase.monad] [all_dependencies (anonymous_dependencies archive inputsTS overriden_methods) [context _] (//////translation.with_new_context archive all_dependencies (in [])) .let [[module_id artifact_id] context @@ -1333,7 +1333,7 @@ (list#each (normalized_method global_mapping)) (monad.each ! (method_definition translate archive artifact_id))) bytecode (<| (of ! each (\\format.result class.format)) - //////.of_try + phase.of_try (class.class version.v6_0 (all modifier#composite class.public class.final) (name.internal anonymous_class_name) {.#None} 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 7b4153a5c..ad59ba175 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 @@ -42,11 +42,10 @@ ["[1][0]" loop]]] [// [analysis (.only)] + ["[0]" phase (.use "[1]#[0]" monad)] ["[0]" translation] ["[0]" synthesis (.only %synthesis) - ["<[1]>" \\parser (.only Parser)]] - [/// - ["[0]" phase (.use "[1]#[0]" monad)]]]]) + ["<[1]>" \\parser (.only Parser)]]]]) (def .public (custom [parser handler]) (All (_ s) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux index 2c0eb4818..8257f1fb1 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/translation/python/host.lux @@ -26,11 +26,10 @@ ["[1][0]" runtime (.only Operation Phase Handler Bundle with_vars)]]] [// + ["[0]" phase] ["[0]" translation] [synthesis - ["" \\parser (.only Parser)]] - [/// - ["[0]" phase]]]]]) + ["" \\parser (.only Parser)]]]]]) (def (array::new size) (Unary (Expression Any)) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux index 825a2e8d6..65f84629a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis.lux @@ -23,13 +23,13 @@ ["/[1]" // ["[0]" extension] ["/[1]" // + ["[0]" phase (.use "[1]#[0]" monad)] ["/" synthesis (.only Synthesis Operation Phase Extender Handler) ["[1][0]" simple]] ["[1][0]" analysis (.only Analysis) ["[2][0]" simple] ["[2][0]" complex]] [/// - ["[0]" phase (.use "[1]#[0]" monad)] [reference (.only) [variable (.only)]] [meta diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux index 76cc4c74e..a448dc50a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/function.lux @@ -22,12 +22,12 @@ ["[0]" // ["[1][0]" loop (.only Transform)] ["//[1]" /// + ["[0]" phase (.use "[1]#[0]" monad)] + ["/" synthesis (.only Path Abstraction Synthesis Operation Phase)] ["[1][0]" analysis (.only Environment Analysis) ["[1]/[0]" complex]] - ["/" synthesis (.only Path Abstraction Synthesis Operation Phase)] [/// [arity (.only Arity)] - ["[0]" phase (.use "[1]#[0]" monad)] ["[1][0]" reference (.only) ["[1]/[0]" variable (.only Register Variable)]]]]]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux index c9dd922ef..94e506f2d 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/loop.lux @@ -15,9 +15,9 @@ [macro ["^" pattern]]]]] [//// + ["/" synthesis (.only Path Abstraction Synthesis)] ["[0]" analysis (.only Environment) ["[1]/[0]" complex]] - ["/" synthesis (.only Path Abstraction Synthesis)] [/// [arity (.only Arity)] ["[0]" reference (.only) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux index cd7de82f5..0af44a404 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/synthesis/when.lux @@ -23,6 +23,7 @@ ["^" pattern]]]]] ["[0]" /// [// + ["[0]" phase (.use "[1]#[0]" monad)] ["[1][0]" analysis (.only Match Analysis) ["[2][0]" simple] ["[2][0]" complex] @@ -32,7 +33,6 @@ ["[2][0]" side] ["[2][0]" member (.only Member)]]] [/// - ["[1]" phase (.use "[1]#[0]" monad)] ["[1][0]" reference (.only) ["[1]/[0]" variable (.only Register Variable)]] [meta @@ -51,15 +51,15 @@ thenC {///simple.#Bit when} - (///#each (function (_ then) - {/.#Bit_Fork when then {.#None}}) - thenC) + (phase#each (function (_ then) + {/.#Bit_Fork when then {.#None}}) + thenC) (^.with_template [ ] [{ test} - (///#each (function (_ then) - { [( test) then] (list)}) - thenC)]) + (phase#each (function (_ then) + { [( test) then] (list)}) + thenC)]) ([///simple.#Nat /.#I64_Fork .i64] [///simple.#Int /.#I64_Fork .i64] [///simple.#Rev /.#I64_Fork .i64] @@ -67,16 +67,16 @@ [///simple.#Text /.#Text_Fork |>])) {///pattern.#Bind register} - (<| (of ///.monad each (|>> {/.#Seq {/.#Bind register}})) + (<| (of phase.monad each (|>> {/.#Seq {/.#Bind register}})) /.with_new_local thenC) {///pattern.#Complex {///complex.#Variant [lefts right? value_pattern]}} - (<| (///#each (|>> {/.#Seq {/.#Access {/access.#Side [/side.#lefts lefts - /side.#right? right?]}}})) + (<| (phase#each (|>> {/.#Seq {/.#Access {/access.#Side [/side.#lefts lefts + /side.#right? right?]}}})) (path' value_pattern end?) (pipe.if [(pipe.new (not end?) [])] - [(///#each ..clean_up)] + [(phase#each ..clean_up)] []) thenC) @@ -90,13 +90,13 @@ _ (let [right? (n.= tuple::last tuple::lefts) end?' (and end? right?)] - (<| (///#each (|>> {/.#Seq {/.#Access {/access.#Member [/member.#lefts (if right? - (-- tuple::lefts) - tuple::lefts) - /member.#right? right?]}}})) + (<| (phase#each (|>> {/.#Seq {/.#Access {/access.#Member [/member.#lefts (if right? + (-- tuple::lefts) + tuple::lefts) + /member.#right? right?]}}})) (path' tuple::member end?') (pipe.if [(pipe.new (not end?') [])] - [(///#each ..clean_up)] + [(phase#each ..clean_up)] []) nextC)))) thenC @@ -105,7 +105,7 @@ (def (path archive synthesize pattern bodyA) (-> Archive Phase Pattern Analysis (Operation Path)) - (path' pattern true (///#each (|>> {/.#Then}) (synthesize archive bodyA)))) + (path' pattern true (phase#each (|>> {/.#Then}) (synthesize archive bodyA)))) (def (weave_branch weave equivalence [new_test new_then] [[old_test old_then] old_tail]) (All (_ a) @@ -245,7 +245,7 @@ (def .public (synthesize_when synthesize @ archive input [[headP headA] tailPA+]) (-> Phase Location Archive Synthesis Match (Operation Synthesis)) - (do [! ///.monad] + (do [! phase.monad] [headSP (path archive synthesize headP headA) tailSP+ (monad.each ! (product.uncurried (path archive synthesize)) tailPA+)] (in (/.branch/when @ [input (list#mix weave headSP tailSP+)])))) @@ -258,13 +258,13 @@ (def .public (synthesize_exec synthesize @ archive before after) (-> Phase Location Archive Synthesis Analysis (Operation Synthesis)) - (do ///.monad + (do phase.monad [after (synthesize archive after)] (in (/.branch/exec @ [before after])))) (def .public (synthesize_let synthesize @ archive input @variable body) (-> Phase Location Archive Synthesis Register Analysis (Operation Synthesis)) - (do ///.monad + (do phase.monad [body (/.with_new_local (synthesize archive body))] (in (/.branch/let @ [input @variable body])))) @@ -272,12 +272,12 @@ (def .public (synthesize_masking synthesize @ archive input @variable @output) (-> Phase Location Archive Synthesis Register Register (Operation Synthesis)) (if (n.= @variable @output) - (///#in input) + (phase#in input) (..synthesize_let synthesize @ archive input @variable [@ {///analysis.#Reference (///reference.local @output)}]))) (def .public (synthesize_if synthesize @ archive test then else) (-> Phase Location Archive Synthesis Analysis Analysis (Operation Synthesis)) - (do ///.monad + (do phase.monad [then (synthesize archive then) else (synthesize archive else)] (in (/.branch/if @ [test then else])))) @@ -295,16 +295,16 @@ (..synthesize_when synthesize @ archive input (!get @ patterns @member)) path - (///#in (when input - (/.branch/get @ [sub_path sub_input]) - (/.branch/get @ [(list#composite sub_path path) sub_input]) + (phase#in (when input + (/.branch/get @ [sub_path sub_input]) + (/.branch/get @ [(list#composite sub_path path) sub_input]) - _ - (/.branch/get @ [path input]))))) + _ + (/.branch/get @ [path input]))))) (def .public (synthesize @ synthesize^ [headB tailB+] archive inputA) (-> Location Phase Match Phase) - (do [! ///.monad] + (do [! phase.monad] [inputS (synthesize^ archive inputA)] (when [headB tailB+] (!masking @ @variable @output) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/extension.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/extension.lux index 38a52d429..a1e19ae0a 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/extension.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/extension.lux @@ -19,9 +19,8 @@ ["[1][0]" extension] [// [synthesis (.only Synthesis)] - ["[0]" translation] - [/// - ["[1]" phase]]]]) + ["[0]" phase] + ["[0]" translation]]]) (def Vector (syntax (_ [size .nat @@ -51,7 +50,7 @@ (function ((, g!_) (, g!phase) (, g!archive) (, g!inputs)) (when (, g!inputs) (list (,* g!input+)) - (do ///.monad + (do phase.monad [(,* (|> g!input+ (list#each (function (_ g!input) (list g!input (` ((, g!phase) (, g!archive) (, g!input)))))) @@ -59,7 +58,7 @@ ((,' in) ((, g!extension) [(,* g!input+)]))) (, g!_) - (///.except ..incorrect_arity [(, (code.nat arity)) (list.size (, g!inputs))])) + (phase.except ..incorrect_arity [(, (code.nat arity)) (list.size (, g!inputs))])) )))))))))) (with_template [ ] @@ -79,7 +78,7 @@ (All (_ anchor expression declaration) (-> (Variadic expression) (translation.Handler anchor expression declaration))) (function (_ phase archive inputsS) - (let [! ///.monad] + (let [! phase.monad] (|> inputsS (monad.each ! (phase archive)) (of ! each extension))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux index bc59b8d93..ac3cec698 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux @@ -27,9 +27,9 @@ ["[1]/[0]" common]]]] ["/[1]" // [analysis (.only)] + ["[0]" phase (.use "[1]#[0]" monad)] ["[1][0]" synthesis] ["//[1]" /// - ["[1][0]" phase (.use "[1]#[0]" monad)] [reference (.only) [variable (.only)]]]]]]]) @@ -41,7 +41,7 @@ (when synthesis (^.with_template [ ] [( @ value) - (//////phase#in ( value))]) + (phase#in ( value))]) ([////synthesis.bit /primitive.bit] [////synthesis.i64 /primitive.i64] [////synthesis.f64 /primitive.f64] @@ -68,7 +68,7 @@ [////synthesis.function/abstraction /function.function]) (////synthesis.loop/again @ updates) - (//////phase.except ..cannot_recur_as_an_expression []) + (phase.except ..cannot_recur_as_an_expression []) [@ {////synthesis.#Reference value}] (//reference.reference /reference.system archive value) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux index f176eb403..49a43f19c 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/function.lux @@ -22,10 +22,10 @@ ["//[1]" /// [analysis (.only Environment Abstraction Reification Analysis)] [synthesis (.only Synthesis)] + ["[0]" phase] ["[1][0]" translation] ["//[1]" /// [arity (.only Arity)] - ["[1][0]" phase] [reference [variable (.only Register Variable)]] [meta @@ -37,7 +37,7 @@ (def .public (apply expression archive [functionS argsS+]) (Translator (Reification Synthesis)) - (do [! ///////phase.monad] + (do [! phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) @@ -50,13 +50,13 @@ (-> artifact.ID SVar (List (Expression Any)) (Statement Any) (Operation (Expression Any))) (when inits {.#End} - (do ///////phase.monad + (do phase.monad [_ (/////translation.execute! function_definition) _ (/////translation.save! function_id {.#None} function_definition)] (in @function)) _ - (do [! ///////phase.monad] + (do [! phase.monad] [.let [declaration (_.def @function (|> (list.enumeration inits) (list#each (|>> product.left ..capture))) @@ -72,7 +72,7 @@ (def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Translator (Abstraction Synthesis))) - (do [! ///////phase.monad] + (do [! phase.monad] [dependencies (cache.dependencies archive bodyS) [[function_module function_artifact] body!] (/////translation.with_new_context archive dependencies (/////translation.with_anchor 1 diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux index 1d4a4a01b..8fa93362b 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/loop.lux @@ -25,10 +25,10 @@ [synthesis ["[0]" when]] ["/[1]" // + ["[0]" phase] ["[0]" synthesis (.only Scope Synthesis)] ["[1][0]" translation] ["//[1]" /// - ["[1][0]" phase] [meta ["[0]" cache [dependency @@ -60,7 +60,7 @@ ... true loop _ - (do [! ///////phase.monad] + (do [! phase.monad] [initsO+ (monad.each ! (expression archive) initsS+) body! (/////translation.with_anchor start (statement expression archive bodyS))] @@ -77,7 +77,7 @@ ... true loop _ - (do [! ///////phase.monad] + (do [! phase.monad] [dependencies (cache.dependencies archive bodyS) initsO+ (monad.each ! (expression archive) initsS+) [[loop_module loop_artifact] body!] (/////translation.with_new_context archive dependencies @@ -113,7 +113,7 @@ (def .public (again! statement expression archive argsS+) (Translator! (List Synthesis)) - (do [! ///////phase.monad] + (do [! phase.monad] [offset /////translation.anchor @temp (//when.symbol "lux_again_values") argsO+ (monad.each ! (expression archive) argsS+) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/runtime.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/runtime.lux index d6fd0eb18..be0a4dd59 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/runtime.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/runtime.lux @@ -30,10 +30,10 @@ ["[0]" /// ["[1][0]" reference] ["//[1]" /// + ["[0]" phase] ["[1][0]" synthesis (.only Synthesis)] ["[1][0]" translation] - ["//[1]" /// (.only) - ["[1][0]" phase] + [/// [reference [variable (.only Register)]] [meta @@ -482,7 +482,7 @@ (def .public translate (Operation [Registry Output]) - (do ///////phase.monad + (do phase.monad [_ (/////translation.execute! ..full_runtime) _ (/////translation.save! ..module_id {.#None} ..full_runtime)] (in [(|> registry.empty diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux index cdca9d0b1..747404963 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/structure.lux @@ -10,27 +10,26 @@ ["[1][0]" runtime (.only Operation Phase Translator)] ["[1][0]" primitive] ["///[1]" //// - [analysis - [complex (.only Variant Tuple)]] + ["[0]" phase (.use "[1]#[0]" monad)] ["[1][0]" synthesis (.only Synthesis)] - ["//[1]" /// - ["[1][0]" phase (.use "[1]#[0]" monad)]]]]) + [analysis + [complex (.only Variant Tuple)]]]]) (def .public (tuple translate archive elemsS+) (Translator (Tuple Synthesis)) (when elemsS+ {.#End} - (///////phase#in (//primitive.text /////synthesis.unit)) + (phase#in (//primitive.text /////synthesis.unit)) {.#Item singletonS {.#End}} (translate archive singletonS) _ (|> elemsS+ - (monad.each ///////phase.monad (translate archive)) - (///////phase#each _.list)))) + (monad.each phase.monad (translate archive)) + (phase#each _.list)))) (def .public (variant translate archive [lefts right? valueS]) (Translator (Variant Synthesis)) - (///////phase#each (//runtime.variant lefts right?) - (translate archive valueS))) + (phase#each (//runtime.variant lefts right?) + (translate archive valueS))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux index e70766b1c..a8555492d 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python/when.lux @@ -28,6 +28,7 @@ [synthesis ["[0]" when]] ["/[1]" // + ["[0]" phase (.use "[1]#[0]" monad)] ["[1][0]" translation] ["[1][0]" synthesis (.only Synthesis Path) [access @@ -35,7 +36,6 @@ ["//[1]" /// [reference ["[1][0]" variable (.only Register)]] - ["[1][0]" phase (.use "[1]#[0]" monad)] [meta [archive (.only Archive)] ["[0]" cache @@ -44,8 +44,8 @@ (def .public (symbol prefix) (-> Text (Operation SVar)) - (///////phase#each (|>> %.nat (format prefix) _.var) - /////translation.next)) + (phase#each (|>> %.nat (format prefix) _.var) + /////translation.next)) (def .public register (-> Register SVar) @@ -57,7 +57,7 @@ (def .public (let expression archive [valueS register bodyS]) (Translator [Synthesis Register Synthesis]) - (do ///////phase.monad + (do phase.monad [valueO (expression archive valueS) bodyO (expression archive bodyS)] ... TODO: Find some way to do 'let' without paying the price of the closure. @@ -67,7 +67,7 @@ (def .public (let! statement expression archive [valueS register bodyS]) (Translator! [Synthesis Register Synthesis]) - (do ///////phase.monad + (do phase.monad [valueO (expression archive valueS) bodyO (statement expression archive bodyS)] (in (all _.then @@ -76,14 +76,14 @@ (def .public (exec expression archive [pre post]) (Translator [Synthesis Synthesis]) - (do ///////phase.monad + (do phase.monad [pre (expression archive pre) post (expression archive post)] (in (_.item (_.int +1) (_.tuple (list pre post)))))) (def .public (exec! statement expression archive [pre post]) (Translator! [Synthesis Synthesis]) - (do ///////phase.monad + (do phase.monad [pre (expression archive pre) post (statement expression archive post)] (in (all _.then @@ -92,7 +92,7 @@ (def .public (if expression archive [testS thenS elseS]) (Translator [Synthesis Synthesis Synthesis]) - (do ///////phase.monad + (do phase.monad [testO (expression archive testS) thenO (expression archive thenS) elseO (expression archive elseS)] @@ -100,7 +100,7 @@ (def .public (if! statement expression archive [testS thenS elseS]) (Translator! [Synthesis Synthesis Synthesis]) - (do ///////phase.monad + (do phase.monad [test! (expression archive testS) then! (statement expression archive thenS) else! (statement expression archive elseS)] @@ -110,7 +110,7 @@ (def .public (get expression archive [pathP valueS]) (Translator [(List Member) Synthesis]) - (do ///////phase.monad + (do phase.monad [valueO (expression archive valueS)] (in (list#mix (function (_ side source) (.let [method (.if (the member.#right? side) @@ -203,7 +203,7 @@ (-> Path (Operation (Maybe (Statement Any))))) (.when pathP {/////synthesis.#Bit_Fork when thenP elseP} - (do [! ///////phase.monad] + (do [! phase.monad] [then! (again thenP) else! (.when elseP {.#Some elseP} @@ -221,7 +221,7 @@ (^.with_template [ ] [{ item} - (do [! ///////phase.monad] + (do [! phase.monad] [clauses (monad.each ! (function (_ [match then]) (of ! each (|>> [(_.= (|> match ) @@ -237,12 +237,12 @@ [/////synthesis.#Text_Fork (<| //primitive.text)]) _ - (of ///////phase.monad in {.#None}))) + (of phase.monad in {.#None}))) (def (pattern_matching' in_closure? statement expression archive) (-> Bit Phase! Phase Archive Path (Operation (Statement Any))) (function (again pathP) - (do [! ///////phase.monad] + (do [! phase.monad] [?output (primitive_pattern_matching again pathP)] (.when ?output {.#Some output} @@ -254,45 +254,45 @@ (statement expression archive bodyS) {/////synthesis.#Pop} - (///////phase#in ..pop!) + (phase#in ..pop!) {/////synthesis.#Bind register} - (///////phase#in (_.set (list (..register register)) ..peek)) + (phase#in (_.set (list (..register register)) ..peek)) (^.with_template [ ] [( idx) - (///////phase#in ( false idx)) + (phase#in ( false idx)) ( idx nextP) (|> nextP again - (///////phase#each (_.then ( true idx))))]) + (phase#each (_.then ( true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) (/////synthesis.member/left 0) - (///////phase#in (|> ..peek (_.item (_.int +0)) ..push!)) + (phase#in (|> ..peek (_.item (_.int +0)) ..push!)) (^.with_template [ ] [( lefts) - (///////phase#in (|> ..peek ( (_.int (.int lefts))) ..push!))]) + (phase#in (|> ..peek ( (_.int (.int lefts))) ..push!))]) ([/////synthesis.member/left //runtime.tuple::left] [/////synthesis.member/right //runtime.tuple::right]) (/////synthesis.!bind_top register thenP) (do ! [then! (again thenP)] - (///////phase#in (all _.then - (_.set (list (..register register)) ..peek_and_pop) - then!))) + (phase#in (all _.then + (_.set (list (..register register)) ..peek_and_pop) + then!))) (/////synthesis.!multi_pop nextP) (.let [[extra_pops nextP'] (when.count_pops nextP)] (do ! [next! (again nextP')] - (///////phase#in (all _.then - (..multi_pop! (n.+ 2 extra_pops)) - next!)))) + (phase#in (all _.then + (..multi_pop! (n.+ 2 extra_pops)) + next!)))) (/////synthesis.path/seq preP postP) (do ! @@ -312,7 +312,7 @@ (def (pattern_matching in_closure? statement expression archive pathP) (-> Bit Phase! Phase Archive Path (Operation (Statement Any))) - (do ///////phase.monad + (do phase.monad [pattern_matching! (pattern_matching' in_closure? statement expression archive pathP) g!once (..symbol "once")] (in (all _.then @@ -335,7 +335,7 @@ (def .public (when! in_closure? statement expression archive [valueS pathP]) (-> Bit (Translator! [Synthesis Path])) - (do ///////phase.monad + (do phase.monad [stack_init (expression archive valueS) pattern_matching! (pattern_matching in_closure? statement expression archive pathP)] (in (all _.then @@ -346,7 +346,7 @@ (def .public (when statement expression archive [valueS pathP]) (-> Phase! (Translator [Synthesis Path])) - (do ///////phase.monad + (do phase.monad [dependencies (cache.path_dependencies archive pathP) [[when_module when_artifact] pattern_matching!] (/////translation.with_new_context archive 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 e9669b5fe..4190683b5 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 @@ -7,10 +7,10 @@ [meta ["@" target] ["[0]" version]]]] - ["[0]" //// - ["[1][0]" translation] - ["//[1]" /// - ["[0]" phase (.use "[1]#[0]" monad)] + [//// + ["[0]" phase (.use "[1]#[0]" monad)] + ["[0]" translation] + [/// ["[0]" reference (.only Reference) ["[0]" variable (.only Register Variable)]] [meta @@ -65,9 +65,9 @@ (def .public (constant system archive name) (All (_ anchor expression declaration) (-> (System expression) Archive Symbol - (////translation.Operation anchor expression declaration expression))) + (translation.Operation anchor expression declaration expression))) (phase#each (|>> ..artifact (of system constant')) - (////translation.remember archive name))) + (translation.remember archive name))) (with_template [ ] [(def .public ( system) @@ -92,7 +92,7 @@ (def .public (reference system archive reference) (All (_ anchor expression declaration) - (-> (System expression) Archive Reference (////translation.Operation anchor expression declaration expression))) + (-> (System expression) Archive Reference (translation.Operation anchor expression declaration expression))) (when reference {reference.#Constant value} (..constant system archive value) 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 0d48bb642..ea8a104a3 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 @@ -22,10 +22,10 @@ ["//[1]" /// [synthesis (.only Synthesis)] [analysis (.only Environment Abstraction Reification Analysis)] + ["[0]" phase] ["[1][0]" translation] ["//[1]" /// [arity (.only Arity)] - ["[1][0]" phase] [reference [variable (.only Register Variable)]] [meta @@ -35,7 +35,7 @@ (def .public (apply expression archive [functionS argsS+]) (Translator (Reification Synthesis)) - (do [! ///////phase.monad] + (do [! phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply_lambda argsO+ functionO)))) @@ -67,7 +67,7 @@ (def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Translator (Abstraction Synthesis))) - (do [! ///////phase.monad] + (do [! phase.monad] [dependencies (cache/artifact.dependencies archive bodyS) [[function_module function_artifact] body!] (/////translation.with_new_context archive dependencies (/////translation.with_anchor 1 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 49c76bdee..a670b4b4b 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 @@ -25,10 +25,10 @@ [synthesis ["[0]" when]] ["/[1]" // + ["[0]" phase] ["[0]" synthesis (.only Scope Synthesis)] ["[1][0]" translation] ["//[1]" /// - ["[1][0]" phase] [reference ["[1][0]" variable (.only Register)]]]]]]]) @@ -57,7 +57,7 @@ ... true loop _ - (do [! ///////phase.monad] + (do [! phase.monad] [initsO+ (monad.each ! (expression archive) initsS+) body! (/////translation.with_anchor start (statement expression archive bodyS))] @@ -74,7 +74,7 @@ ... true loop _ - (do [! ///////phase.monad] + (do [! phase.monad] [body! (scope! statement expression archive [start initsS+ bodyS])] (in (|> body! [(list)] (_.lambda {.#None}) @@ -82,7 +82,7 @@ (def .public (again! statement expression archive argsS+) (Translator! (List Synthesis)) - (do [! ///////phase.monad] + (do [! phase.monad] [offset /////translation.anchor @temp (//when.symbol "lux_again_values") argsO+ (monad.each ! (expression archive) argsS+) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/runtime.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/runtime.lux index 3bf36726d..8be246d69 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/runtime.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/ruby/runtime.lux @@ -29,10 +29,10 @@ ["[0]" /// ["[1][0]" reference] ["//[1]" /// + ["[0]" phase] ["[1][0]" synthesis (.only Synthesis)] ["[1][0]" translation] - ["//[1]" /// (.only) - ["[1][0]" phase] + [/// [reference [variable (.only Register)]] [meta @@ -625,7 +625,7 @@ (def .public translate (Operation [Registry Output]) - (do ///////phase.monad + (do phase.monad [_ (/////translation.execute! ..full) _ (/////translation.save! ..module_id {.#None} ..full)] (in [(|> registry.empty 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 748d4be1d..100ebd54f 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 @@ -10,27 +10,26 @@ ["[1][0]" runtime (.only Operation Phase Translator)] ["[1][0]" primitive] ["///[1]" //// - [analysis - [complex (.only Variant Tuple)]] + ["[0]" phase (.use "[1]#[0]" monad)] ["[1][0]" synthesis (.only Synthesis)] - ["//[1]" /// - ["[1][0]" phase (.use "[1]#[0]" monad)]]]]) + [analysis + [complex (.only Variant Tuple)]]]]) (def .public (tuple translate archive elemsS+) (Translator (Tuple Synthesis)) (when elemsS+ {.#End} - (///////phase#in (//primitive.text /////synthesis.unit)) + (phase#in (//primitive.text /////synthesis.unit)) {.#Item singletonS {.#End}} (translate archive singletonS) _ (|> elemsS+ - (monad.each ///////phase.monad (translate archive)) - (///////phase#each _.array)))) + (monad.each phase.monad (translate archive)) + (phase#each _.array)))) (def .public (variant translate archive [lefts right? valueS]) (Translator (Variant Synthesis)) - (///////phase#each (//runtime.variant lefts right?) - (translate archive valueS))) + (phase#each (//runtime.variant lefts right?) + (translate archive valueS))) 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 ea2520b18..f2f982e09 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 @@ -28,6 +28,7 @@ [synthesis ["[0]" when]] ["/[1]" // + ["[0]" phase (.use "[1]#[0]" monad)] ["[1][0]" translation] ["[1][0]" synthesis (.only Synthesis Path) [access @@ -35,13 +36,12 @@ ["//[1]" /// [reference ["[1][0]" variable (.only Register)]] - ["[1][0]" phase (.use "[1]#[0]" monad)] [meta [archive (.only Archive)]]]]]]]) (def .public (symbol prefix) (-> Text (Operation LVar)) - (///////phase#each (|>> %.nat (format prefix) _.local) /////translation.next)) + (phase#each (|>> %.nat (format prefix) _.local) /////translation.next)) (def .public register (-> Register LVar) @@ -53,7 +53,7 @@ (def .public (exec expression archive [this that]) (Translator [Synthesis Synthesis]) - (do ///////phase.monad + (do phase.monad [this (expression archive this) that (expression archive that)] (in (|> (_.array (list this that)) @@ -61,7 +61,7 @@ (def .public (exec! statement expression archive [this that]) (Translator! [Synthesis Synthesis]) - (do ///////phase.monad + (do phase.monad [this (expression archive this) that (statement expression archive that)] (in (all _.then @@ -71,7 +71,7 @@ (def .public (let expression archive [valueS register bodyS]) (Translator [Synthesis Register Synthesis]) - (do ///////phase.monad + (do phase.monad [valueO (expression archive valueS) bodyO (expression archive bodyS)] ... TODO: Find some way to do 'let' without paying the price of the closure. @@ -82,7 +82,7 @@ (def .public (let! statement expression archive [valueS register bodyS]) (Translator! [Synthesis Register Synthesis]) - (do ///////phase.monad + (do phase.monad [valueO (expression archive valueS) bodyO (statement expression archive bodyS)] (in (all _.then @@ -91,7 +91,7 @@ (def .public (if expression archive [testS thenS elseS]) (Translator [Synthesis Synthesis Synthesis]) - (do ///////phase.monad + (do phase.monad [testO (expression archive testS) thenO (expression archive thenS) elseO (expression archive elseS)] @@ -99,7 +99,7 @@ (def .public (if! statement expression archive [testS thenS elseS]) (Translator! [Synthesis Synthesis Synthesis]) - (do ///////phase.monad + (do phase.monad [test! (expression archive testS) then! (statement expression archive thenS) else! (statement expression archive elseS)] @@ -109,7 +109,7 @@ (def .public (get expression archive [pathP valueS]) (Translator [(List Member) Synthesis]) - (do ///////phase.monad + (do phase.monad [valueO (expression archive valueS)] (in (list#mix (function (_ side source) (.let [method (.if (the member.#right? side) @@ -210,7 +210,7 @@ (-> Path (Operation (Maybe Statement)))) (.when pathP {/////synthesis.#Bit_Fork when thenP elseP} - (do [! ///////phase.monad] + (do [! phase.monad] [then! (again thenP) else! (.when elseP {.#Some elseP} @@ -228,7 +228,7 @@ (^.with_template [ ] [{ item} - (do [! ///////phase.monad] + (do [! phase.monad] [clauses (monad.each ! (function (_ [match then]) (of ! each (|>> [(_.= (|> match ) @@ -244,12 +244,12 @@ [/////synthesis.#Text_Fork (<| //primitive.text)]) _ - (of ///////phase.monad in {.#None}))) + (of phase.monad in {.#None}))) (def (pattern_matching' in_closure? statement expression archive) (-> Bit (Translator! Path)) (function (again pathP) - (do ///////phase.monad + (do phase.monad [?output (primitive_pattern_matching again pathP)] (.when ?output {.#Some output} @@ -261,13 +261,13 @@ (statement expression archive bodyS) {/////synthesis.#Pop} - (///////phase#in ..pop!) + (phase#in ..pop!) {/////synthesis.#Bind register} - (///////phase#in (_.set (list (..register register)) ..peek)) + (phase#in (_.set (list (..register register)) ..peek)) {/////synthesis.#Bit_Fork when thenP elseP} - (do [! ///////phase.monad] + (do [! phase.monad] [then! (again thenP) else! (.when elseP {.#Some elseP} @@ -285,7 +285,7 @@ (^.with_template [ ] [{ item} - (do [! ///////phase.monad] + (do [! phase.monad] [clauses (monad.each ! (function (_ [match then]) (of ! each (|>> [(_.= (|> match ) @@ -302,41 +302,41 @@ (^.with_template [ ] [( idx) - (///////phase#in ( false idx)) + (phase#in ( false idx)) ( idx nextP) (|> nextP again - (///////phase#each (_.then ( true idx))))]) + (phase#each (_.then ( true idx))))]) ([/////synthesis.side/left /////synthesis.simple_left_side ..left_choice] [/////synthesis.side/right /////synthesis.simple_right_side ..right_choice]) (/////synthesis.member/left 0) - (///////phase#in (|> ..peek (_.item (_.int +0)) ..push!)) + (phase#in (|> ..peek (_.item (_.int +0)) ..push!)) (^.with_template [ ] [( lefts) - (///////phase#in (|> ..peek ( (_.int (.int lefts))) ..push!))]) + (phase#in (|> ..peek ( (_.int (.int lefts))) ..push!))]) ([/////synthesis.member/left //runtime.tuple//left] [/////synthesis.member/right //runtime.tuple//right]) (/////synthesis.!bind_top register thenP) - (do ///////phase.monad + (do phase.monad [then! (again thenP)] - (///////phase#in (all _.then - (_.set (list (..register register)) ..peek_and_pop) - then!))) + (phase#in (all _.then + (_.set (list (..register register)) ..peek_and_pop) + then!))) (/////synthesis.!multi_pop nextP) (.let [[extra_pops nextP'] (when.count_pops nextP)] - (do ///////phase.monad + (do phase.monad [next! (again nextP')] - (///////phase#in (all _.then - (..multi_pop! (n.+ 2 extra_pops)) - next!)))) + (phase#in (all _.then + (..multi_pop! (n.+ 2 extra_pops)) + next!)))) (/////synthesis.path/seq preP postP) - (do ///////phase.monad + (do phase.monad [pre! (again preP) post! (again postP)] (in (all _.then @@ -344,7 +344,7 @@ post!))) (/////synthesis.path/alt preP postP) - (do ///////phase.monad + (do phase.monad [pre! (again preP) post! (again postP) g!once (..symbol "once") @@ -353,7 +353,7 @@ (def (pattern_matching in_closure? statement expression archive pathP) (-> Bit (Translator! Path)) - (do ///////phase.monad + (do phase.monad [pattern_matching! (pattern_matching' in_closure? statement expression archive pathP) g!once (..symbol "once") g!continue? (..symbol "continue")] @@ -364,7 +364,7 @@ (def .public (when! in_closure? statement expression archive [valueS pathP]) (-> Bit (Translator! [Synthesis Path])) - (do ///////phase.monad + (do phase.monad [stack_init (expression archive valueS) pattern_matching! (pattern_matching in_closure? statement expression archive pathP)] (in (all _.then @@ -377,6 +377,6 @@ (-> Phase! (Translator [Synthesis Path])) (|> when (when! true statement expression archive) - (of ///////phase.monad each + (of phase.monad each (|>> [(list)] (_.lambda {.#None}) (_.apply_lambda (list)))))) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux index 2ceef9fd2..1c58de2b8 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux @@ -18,10 +18,10 @@ ["[0]" dictionary (.only Dictionary)]]] [math [number - ["[0]" i64] ["n" nat] ["i" int] - ["f" frac]]] + ["f" frac] + ["[0]" i64]]] [meta [macro ["^" pattern]]]]] @@ -33,11 +33,10 @@ [// ["[0]" analysis (.only Environment Analysis) ["[1]/[0]" complex (.only Complex)]] - [phase + ["[0]" phase (.only) ["[0]" extension (.only Extension)]] [/// [arity (.only Arity)] - ["[0]" phase] ["[0]" reference (.only Reference) ["[0]" variable (.only Register Variable)]]]]]) diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/translation.lux b/stdlib/source/library/lux/meta/compiler/language/lux/translation.lux index 521cbf541..cb92a5e51 100644 --- a/stdlib/source/library/lux/meta/compiler/language/lux/translation.lux +++ b/stdlib/source/library/lux/meta/compiler/language/lux/translation.lux @@ -26,10 +26,9 @@ ["[0]" template]]]]] [// [synthesis (.only Synthesis)] - [phase + ["[0]" phase (.only) ["[0]" extension]] [/// - ["[0]" phase] [meta ["[0]" archive (.only Archive) ["[0]" registry (.only Registry)] diff --git a/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux b/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux index 3b8021224..e9128d16b 100644 --- a/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux +++ b/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/artifact.lux @@ -20,10 +20,10 @@ [macro ["^" pattern]] [compiler - ["[0]" phase] ["[0]" reference (.only Constant)] [language [lux + ["[0]" phase] ["[0]" synthesis (.only Synthesis Path)] ["[0]" translation (.only Operation)] ["[0]" analysis diff --git a/stdlib/source/library/lux/meta/compiler/phase.lux b/stdlib/source/library/lux/meta/compiler/phase.lux deleted file mode 100644 index ddd18c7b6..000000000 --- a/stdlib/source/library/lux/meta/compiler/phase.lux +++ /dev/null @@ -1,183 +0,0 @@ -(.require - [library - [lux (.except except with try) - [abstract - [functor (.only Functor)] - [monad (.only Monad do)]] - [control - ["[0]" state] - ["[0]" try (.only Try) (.use "[1]#[0]" functor)] - ["[0]" exception (.only Exception)] - ["[0]" io]] - [data - ["[0]" product] - [text - ["%" \\format (.only format)]]] - [world - [time - ["[0]" instant] - ["[0]" duration]]]]] - [// - [meta - [archive (.only Archive)]]]) - -(type .public (Operation s o) - (state.+State Try s o)) - -(def .public functor - (All (_ s) (Functor (Operation s))) - (implementation - (def (each f it) - (function (_ state) - (when (it state) - {try.#Success [state' output]} - {try.#Success [state' (f output)]} - - {try.#Failure error} - {try.#Failure error}))))) - -(def .public monad - (All (_ s) (Monad (Operation s))) - (implementation - (def functor ..functor) - - (def (in it) - (function (_ state) - {try.#Success [state it]})) - - (def (conjoint it) - (function (_ state) - (when (it state) - {try.#Success [state' it']} - (it' state') - - {try.#Failure error} - {try.#Failure error}))))) - -(type .public (Phase s i o) - (-> Archive i (Operation s o))) - -(type .public Wrapper - (All (_ s i o) (-> (Phase s i o) Any))) - -(def .public (result' state operation) - (All (_ s o) - (-> s (Operation s o) (Try [s o]))) - (operation state)) - -(def .public (result state operation) - (All (_ s o) - (-> s (Operation s o) (Try o))) - (|> state - operation - (of try.monad each product.right))) - -(def .public state - (All (_ s o) - (Operation s s)) - (function (_ state) - {try.#Success [state state]})) - -(def .public (with state) - (All (_ s o) - (-> s (Operation s Any))) - (function (_ _) - {try.#Success [state []]})) - -(def .public (sub [get set] operation) - (All (_ s s' o) - (-> [(-> s s') (-> s' s s)] - (Operation s' o) - (Operation s o))) - (function (_ state) - (do try.monad - [[state' output] (operation (get state))] - (in [(set state' state) output])))) - -(def .public failure - (-> Text Operation) - (|>> {try.#Failure} (state.lifted try.monad))) - -(def .public (except exception parameters) - (All (_ e) (-> (Exception e) e Operation)) - (..failure (exception.error exception parameters))) - -(def .public (of_try error) - (All (_ state of) - (-> (Try of) - (Operation state of))) - (function (_ state) - (try#each (|>> [state]) error))) - -(def .public assertion - (template (_ exception message test) - [(if test - (of ..monad in []) - (..except exception message))])) - -(def .public (try it) - (All (_ state value) - (-> (Operation state value) - (Operation state (Try value)))) - (function (_ state) - (when (it state) - {try.#Success [state' it']} - {try.#Success [state' {try.#Success it'}]} - - {try.#Failure error} - {try.#Success [state {try.#Failure error}]}))) - -(def .public identity - (All (_ s a) (Phase s a a)) - (function (_ archive input state) - {try.#Success [state input]})) - -(def .public (composite pre post) - (All (_ s0 s1 i t o) - (-> (Phase s0 i t) - (Phase s1 t o) - (Phase [s0 s1] i o))) - (function (_ archive input [pre/state post/state]) - (do try.monad - [[pre/state' temp] (pre archive input pre/state) - [post/state' output] (post archive temp post/state)] - (in [[pre/state' post/state'] output])))) - -(def .public (read get) - (All (_ s v) - (-> (-> s v) (Operation s v))) - (function (_ state) - {try.#Success [state (get state)]})) - -(def .public (update transform) - (All (_ s) - (-> (-> s s) (Operation s Any))) - (function (_ state) - {try.#Success [(transform state) []]})) - -(def .public (localized get set transform) - (All (_ s s' v) - (-> (-> s s') (-> s' s s) (-> s' s') - (-> (Operation s v) (Operation s v)))) - (function (_ operation) - (function (_ state) - (let [old (get state)] - (when (operation (set (transform old) state)) - {try.#Success [state' output]} - {try.#Success [(set old state') output]} - - failure - failure))))) - -(def .public (temporary transform) - (All (_ s v) - (-> (-> s s) - (-> (Operation s v) (Operation s v)))) - (function (_ operation) - (function (_ state) - (when (operation (transform state)) - {try.#Success [state' output]} - {try.#Success [state output]} - - failure - failure)))) diff --git a/stdlib/source/library/lux/meta/extension.lux b/stdlib/source/library/lux/meta/extension.lux index 7365e2442..e44345492 100644 --- a/stdlib/source/library/lux/meta/extension.lux +++ b/stdlib/source/library/lux/meta/extension.lux @@ -23,9 +23,9 @@ [syntax (.only syntax)] ["[0]" template]] [compiler - ["[0]" phase] [language [lux + ["[0]" phase] ["[0]" analysis (.only) ["" \\parser]] ["[0]" synthesis (.only) diff --git a/stdlib/source/library/lux/web/css/value.lux b/stdlib/source/library/lux/web/css/value.lux index c23a1fda0..2ff369bc7 100644 --- a/stdlib/source/library/lux/web/css/value.lux +++ b/stdlib/source/library/lux/web/css/value.lux @@ -832,17 +832,17 @@ (def .public (rgb color) (-> RGB (Value Color)) - (..apply "rgb" (list (%.nat (rgb.red color)) - (%.nat (rgb.green color)) - (%.nat (rgb.blue color))))) + (..apply "rgb" (list (%.nat (the rgb.#red color)) + (%.nat (the rgb.#green color)) + (%.nat (the rgb.#blue color))))) (def .public (rgba pigment) (-> Pigment (Value Color)) (let [(open "/[0]") pigment] - (..apply "rgba" (list (%.nat (rgb.red /#color)) - (%.nat (rgb.green /#color)) - (%.nat (rgb.blue /#color)) + (..apply "rgba" (list (%.nat (the rgb.#red /#color)) + (%.nat (the rgb.#green /#color)) + (%.nat (the rgb.#blue /#color)) (if (r.= (of r.interval top) /#alpha) "1.0" (format "0" (%.rev /#alpha))))))) diff --git a/stdlib/source/library/lux/world/finance/money.lux b/stdlib/source/library/lux/world/finance/money.lux new file mode 100644 index 000000000..cd0724459 --- /dev/null +++ b/stdlib/source/library/lux/world/finance/money.lux @@ -0,0 +1,151 @@ +(.require + [library + [lux (.except) + [abstract + [equivalence (.only Equivalence)] + ["[0]" order (.only Order)]] + [data + ["[0]" product] + ["[0]" text (.only) + ["%" \\format]]] + [math + [number + ["n" nat]]] + [meta + ["[0]" static] + [type + ["[0]" nominal]]]]] + [/ + ["/" currency]]) + +(nominal.def .public (Money currency) + (Record + [#currency (/.Currency currency) + #amount Nat]) + + (def .public (money currency amount) + (All (_ currency) + (-> (/.Currency currency) Nat + (Money currency))) + (nominal.abstraction + [#currency currency + #amount amount])) + + (def .public (of_units currency it) + (All (_ currency) + (-> (/.Currency currency) Nat + (Money currency))) + (money currency + (n.* (/.sub_divisions currency) + it))) + + (def .public of_sub_units money) + + (with_template [ ] + [(def .public + (All (_ currency) + (-> (Money currency) + )) + (|>> nominal.representation + (the )))] + + [currency #currency (/.Currency currency)] + [amount #amount Nat] + ) + + (def .public order + (All (_ currency) + (Order (Money currency))) + (of order.functor each + ..amount + n.order)) + + (def .public < + (All (_ currency) + (-> (Money currency) (Money currency) + Bit)) + (of ..order <)) + + (with_template [ ] + [(def .public + (All (_ currency) + (-> (Money currency) (Money currency) + Bit)) + ( order))] + + [<= order.<=] + [> order.>] + [>= order.>=] + ) + + (def .public equivalence + (All (_ currency) + (Equivalence (Money currency))) + (of ..order equivalence)) + + (def .public = + (All (_ currency) + (-> (Money currency) (Money currency) + Bit)) + (of ..equivalence =)) + + (def .public (+ parameter subject) + (All (_ currency) + (-> (Money currency) (Money currency) + (Money currency))) + (|> subject + nominal.representation + (revised #amount (n.+ (|> parameter nominal.representation (the #amount)))) + nominal.abstraction)) + + (def .public (- parameter subject) + (All (_ currency) + (-> (Money currency) (Money currency) + (Maybe (Money currency)))) + (let [parameter (nominal.representation parameter) + subject (nominal.representation subject)] + (if (n.< (the #amount parameter) + (the #amount subject)) + {.#None} + {.#Some (nominal.abstraction + [#currency (the #currency subject) + #amount (n.- (the #amount parameter) + (the #amount subject))])}))) + + (def .public (format it) + (All (_ currency) + (%.Format (Money currency))) + (let [[currency amount] (nominal.representation it) + [macro micro] (n./% (/.sub_divisions currency) amount)] + (%.format (%.nat macro) + (when micro + 0 "" + _ (%.format "." (%.nat micro))) + " " (/.alphabetic_code currency)))) + ) + +(with_template [ ] + [(def .public ( left right) + (All (_ currency) + (-> (Money currency) (Money currency) + (Money currency))) + (if ( (..amount left) + (..amount right)) + right + left))] + + [n.< min] + [n.> max] + ) + +(with_template [<*> ] + [(def .public ( it) + (All (_ currency) + (-> (Money currency) + Nat)) + (<*> (/.sub_divisions (..currency it)) + (..amount it)))] + + [n./ units] + [n.% sub_units] + ) diff --git a/stdlib/source/library/lux/world/finance/money/currency.lux b/stdlib/source/library/lux/world/finance/money/currency.lux new file mode 100644 index 000000000..04292fa48 --- /dev/null +++ b/stdlib/source/library/lux/world/finance/money/currency.lux @@ -0,0 +1,283 @@ +... https://en.wikipedia.org/wiki/Currency +(.require + [library + [lux (.except type all try) + [abstract + ["[0]" equivalence (.only Equivalence)] + [monad (.only do)]] + [control + ["?" parser]] + [data + ["[0]" product] + ["[0]" text]] + [math + [number + ["n" nat]]] + ["[0]" meta (.only) + ["[0]" macro (.only) + [syntax (.only syntax)]] + ["[0]" code + ["?[1]" \\parser]] + ["[0]" type (.only) + ["?[1]" \\parser] + ["[0]" nominal]]]]]) + +(nominal.def .public (Currency of) + (Record + [#alphabetic_code Text + #numeric_code Nat + #sub_divisions Nat]) + + (def .public (currency [alphabetic_code numeric_code sub_divisions]) + (Ex (_ of) + (-> [Text Nat Nat] + (Currency of))) + (nominal.abstraction + [#alphabetic_code alphabetic_code + #numeric_code numeric_code + #sub_divisions sub_divisions])) + + (with_template [ ] + [(def .public + (All (_ of) + (-> (Currency of) + )) + (|>> nominal.representation + (the )))] + + [alphabetic_code #alphabetic_code Text] + [numeric_code #numeric_code Nat] + [sub_divisions #sub_divisions Nat] + ) + + (def .public equivalence + (Equivalence (Currency Any)) + (of equivalence.functor each + (|>> nominal.representation) + (.all product.equivalence + text.equivalence + n.equivalence + n.equivalence + ))) + ) + +(def .public type + (syntax (_ [it ?code.any]) + (macro.with_symbols ['_ 'of] + (do meta.monad + [it (meta.eval Type (` (.type_of ((is (All ((, '_) (, 'of)) + (-> (..Currency (, 'of)) + (..Currency (, 'of)))) + (|>>)) + (, it))))) + of (|> (as Type it) + (?type.result (?type.applied (?.after (?type.exactly ..Currency) + ?type.any))) + meta.of_try)] + (in (list (type.code of))))))) + +(def (power parameter subject) + (-> Nat Nat + Nat) + (when parameter + 0 1 + _ (|> subject + (power (-- parameter)) + (n.* subject)))) + +... https://en.wikipedia.org/wiki/ISO_4217 +(with_template [ ] + [(def .public + (..currency [ + + (power 10)])) + + (def .public + Type + (let [[module short] (symbol .._)] + {.#Named [module ] + (..type )})) + + (def .public + (Currency ) + )] + + [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/finance/trade/session.lux b/stdlib/source/library/lux/world/finance/trade/session.lux new file mode 100644 index 000000000..821135300 --- /dev/null +++ b/stdlib/source/library/lux/world/finance/trade/session.lux @@ -0,0 +1,67 @@ +(.require + [library + [lux (.except) + [abstract + [equivalence (.only Equivalence)]] + [data + [text + ["%" \\format (.only Format)]]] + [math + [number + ["n" nat]]]]] + [/// + ["[0]" money (.only Money) + [currency (.only Currency)]]]) + +(type .public (Price $) + (Money $)) + +(type .public Volume + Nat) + +(type .public (Session $) + (Record + [#open (Price $) + #high (Price $) + #low (Price $) + #close (Price $) + #volume Volume])) + +(def .public equivalence + (All (_ $) + (Equivalence (Session $))) + (implementation + (def (= reference subject) + (`` (and (,, (with_template [<=> ] + [(<=> (the reference) (the subject))] + + [money.= #open] + [money.= #high] + [money.= #low] + [money.= #close] + [n.= #volume] + ))))))) + +(def .public (composite before after) + (All (_ $) + (-> (Session $) (Session $) + (Session $))) + [#open (the #open before) + #high (money.max (the #high before) (the #high after)) + #low (money.min (the #low before) (the #low after)) + #close (the #close after) + #volume (n.+ (the #volume before) (the #volume after))]) + +... https://en.wikipedia.org/wiki/Open-high-low-close_chart +(def .public (format it) + (All (_ $) + (Format (Session $))) + (`` (%.format (,, (with_template [
] + [
": " (`` ( (the it)))] + + ["O" #open money.format] + [" | H" #high money.format] + [" | L" #low money.format] + [" | C" #close money.format] + [" | V" #volume %.nat] + ))))) diff --git a/stdlib/source/library/lux/world/money.lux b/stdlib/source/library/lux/world/money.lux deleted file mode 100644 index cd0724459..000000000 --- a/stdlib/source/library/lux/world/money.lux +++ /dev/null @@ -1,151 +0,0 @@ -(.require - [library - [lux (.except) - [abstract - [equivalence (.only Equivalence)] - ["[0]" order (.only Order)]] - [data - ["[0]" product] - ["[0]" text (.only) - ["%" \\format]]] - [math - [number - ["n" nat]]] - [meta - ["[0]" static] - [type - ["[0]" nominal]]]]] - [/ - ["/" currency]]) - -(nominal.def .public (Money currency) - (Record - [#currency (/.Currency currency) - #amount Nat]) - - (def .public (money currency amount) - (All (_ currency) - (-> (/.Currency currency) Nat - (Money currency))) - (nominal.abstraction - [#currency currency - #amount amount])) - - (def .public (of_units currency it) - (All (_ currency) - (-> (/.Currency currency) Nat - (Money currency))) - (money currency - (n.* (/.sub_divisions currency) - it))) - - (def .public of_sub_units money) - - (with_template [ ] - [(def .public - (All (_ currency) - (-> (Money currency) - )) - (|>> nominal.representation - (the )))] - - [currency #currency (/.Currency currency)] - [amount #amount Nat] - ) - - (def .public order - (All (_ currency) - (Order (Money currency))) - (of order.functor each - ..amount - n.order)) - - (def .public < - (All (_ currency) - (-> (Money currency) (Money currency) - Bit)) - (of ..order <)) - - (with_template [ ] - [(def .public - (All (_ currency) - (-> (Money currency) (Money currency) - Bit)) - ( order))] - - [<= order.<=] - [> order.>] - [>= order.>=] - ) - - (def .public equivalence - (All (_ currency) - (Equivalence (Money currency))) - (of ..order equivalence)) - - (def .public = - (All (_ currency) - (-> (Money currency) (Money currency) - Bit)) - (of ..equivalence =)) - - (def .public (+ parameter subject) - (All (_ currency) - (-> (Money currency) (Money currency) - (Money currency))) - (|> subject - nominal.representation - (revised #amount (n.+ (|> parameter nominal.representation (the #amount)))) - nominal.abstraction)) - - (def .public (- parameter subject) - (All (_ currency) - (-> (Money currency) (Money currency) - (Maybe (Money currency)))) - (let [parameter (nominal.representation parameter) - subject (nominal.representation subject)] - (if (n.< (the #amount parameter) - (the #amount subject)) - {.#None} - {.#Some (nominal.abstraction - [#currency (the #currency subject) - #amount (n.- (the #amount parameter) - (the #amount subject))])}))) - - (def .public (format it) - (All (_ currency) - (%.Format (Money currency))) - (let [[currency amount] (nominal.representation it) - [macro micro] (n./% (/.sub_divisions currency) amount)] - (%.format (%.nat macro) - (when micro - 0 "" - _ (%.format "." (%.nat micro))) - " " (/.alphabetic_code currency)))) - ) - -(with_template [ ] - [(def .public ( left right) - (All (_ currency) - (-> (Money currency) (Money currency) - (Money currency))) - (if ( (..amount left) - (..amount right)) - right - left))] - - [n.< min] - [n.> max] - ) - -(with_template [<*> ] - [(def .public ( it) - (All (_ currency) - (-> (Money currency) - Nat)) - (<*> (/.sub_divisions (..currency it)) - (..amount it)))] - - [n./ units] - [n.% sub_units] - ) diff --git a/stdlib/source/library/lux/world/money/currency.lux b/stdlib/source/library/lux/world/money/currency.lux deleted file mode 100644 index 04292fa48..000000000 --- a/stdlib/source/library/lux/world/money/currency.lux +++ /dev/null @@ -1,283 +0,0 @@ -... https://en.wikipedia.org/wiki/Currency -(.require - [library - [lux (.except type all try) - [abstract - ["[0]" equivalence (.only Equivalence)] - [monad (.only do)]] - [control - ["?" parser]] - [data - ["[0]" product] - ["[0]" text]] - [math - [number - ["n" nat]]] - ["[0]" meta (.only) - ["[0]" macro (.only) - [syntax (.only syntax)]] - ["[0]" code - ["?[1]" \\parser]] - ["[0]" type (.only) - ["?[1]" \\parser] - ["[0]" nominal]]]]]) - -(nominal.def .public (Currency of) - (Record - [#alphabetic_code Text - #numeric_code Nat - #sub_divisions Nat]) - - (def .public (currency [alphabetic_code numeric_code sub_divisions]) - (Ex (_ of) - (-> [Text Nat Nat] - (Currency of))) - (nominal.abstraction - [#alphabetic_code alphabetic_code - #numeric_code numeric_code - #sub_divisions sub_divisions])) - - (with_template [ ] - [(def .public - (All (_ of) - (-> (Currency of) - )) - (|>> nominal.representation - (the )))] - - [alphabetic_code #alphabetic_code Text] - [numeric_code #numeric_code Nat] - [sub_divisions #sub_divisions Nat] - ) - - (def .public equivalence - (Equivalence (Currency Any)) - (of equivalence.functor each - (|>> nominal.representation) - (.all product.equivalence - text.equivalence - n.equivalence - n.equivalence - ))) - ) - -(def .public type - (syntax (_ [it ?code.any]) - (macro.with_symbols ['_ 'of] - (do meta.monad - [it (meta.eval Type (` (.type_of ((is (All ((, '_) (, 'of)) - (-> (..Currency (, 'of)) - (..Currency (, 'of)))) - (|>>)) - (, it))))) - of (|> (as Type it) - (?type.result (?type.applied (?.after (?type.exactly ..Currency) - ?type.any))) - meta.of_try)] - (in (list (type.code of))))))) - -(def (power parameter subject) - (-> Nat Nat - Nat) - (when parameter - 0 1 - _ (|> subject - (power (-- parameter)) - (n.* subject)))) - -... https://en.wikipedia.org/wiki/ISO_4217 -(with_template [ ] - [(def .public - (..currency [ - - (power 10)])) - - (def .public - Type - (let [[module short] (symbol .._)] - {.#Named [module ] - (..type )})) - - (def .public - (Currency ) - )] - - [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] - ) -- cgit v1.2.3