aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library')
-rw-r--r--stdlib/source/library/lux/math/arithmetic.lux5
-rw-r--r--stdlib/source/library/lux/math/arithmetic/fixed_point.lux1
-rw-r--r--stdlib/source/library/lux/math/arithmetic/saturation.lux1
-rw-r--r--stdlib/source/library/lux/math/number/complex.lux3
-rw-r--r--stdlib/source/library/lux/math/number/frac.lux3
-rw-r--r--stdlib/source/library/lux/math/number/i32.lux24
-rw-r--r--stdlib/source/library/lux/math/number/int.lux3
-rw-r--r--stdlib/source/library/lux/math/number/nat.lux3
-rw-r--r--stdlib/source/library/lux/math/number/ratio.lux3
-rw-r--r--stdlib/source/library/lux/math/number/rev.lux3
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux3
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux4
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/archive/key.lux8
-rw-r--r--stdlib/source/library/lux/world/finance/market/price.lux151
-rw-r--r--stdlib/source/library/lux/world/finance/money.lux21
-rw-r--r--stdlib/source/library/lux/world/finance/trade/session.lux7
17 files changed, 201 insertions, 44 deletions
diff --git a/stdlib/source/library/lux/math/arithmetic.lux b/stdlib/source/library/lux/math/arithmetic.lux
index 46488890a..cad6653c7 100644
--- a/stdlib/source/library/lux/math/arithmetic.lux
+++ b/stdlib/source/library/lux/math/arithmetic.lux
@@ -16,7 +16,4 @@
*)
(is (-> of of
of)
- /)
- (is (-> of of
- of)
- %)))
+ /)))
diff --git a/stdlib/source/library/lux/math/arithmetic/fixed_point.lux b/stdlib/source/library/lux/math/arithmetic/fixed_point.lux
index 717d4261e..db7e4102b 100644
--- a/stdlib/source/library/lux/math/arithmetic/fixed_point.lux
+++ b/stdlib/source/library/lux/math/arithmetic/fixed_point.lux
@@ -174,7 +174,6 @@
(def - (..- @))
(def * (..* @))
(def / (../ @))
- (def % (..% @))
))
(def .public (format @ it)
diff --git a/stdlib/source/library/lux/math/arithmetic/saturation.lux b/stdlib/source/library/lux/math/arithmetic/saturation.lux
index cb72169ce..4ded512df 100644
--- a/stdlib/source/library/lux/math/arithmetic/saturation.lux
+++ b/stdlib/source/library/lux/math/arithmetic/saturation.lux
@@ -22,5 +22,4 @@
[-]
[*]
[/]
- [%]
))))))
diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux
index 518da2518..4a435c693 100644
--- a/stdlib/source/library/lux/math/number/complex.lux
+++ b/stdlib/source/library/lux/math/number/complex.lux
@@ -154,8 +154,7 @@
(def + ..+)
(def - ..-)
(def * ..*)
- (def / ../)
- (def % ..%)))
+ (def / ../)))
(def .public (cos subject)
(-> Complex
diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux
index b6c4f3f20..6dcac2a10 100644
--- a/stdlib/source/library/lux/math/number/frac.lux
+++ b/stdlib/source/library/lux/math/number/frac.lux
@@ -520,8 +520,7 @@
(def + ..+)
(def - ..-)
(def * ..*)
- (def / ../)
- (def % ..%)))
+ (def / ../)))
(def .public (/% param subject)
(-> Frac Frac
diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux
index 4f588d46b..3fc667291 100644
--- a/stdlib/source/library/lux/math/number/i32.lux
+++ b/stdlib/source/library/lux/math/number/i32.lux
@@ -8,6 +8,7 @@
["[0]" maybe]
["[0]" try]]
[meta
+ ["@" target]
["[0]" static]
["[0]" type (.only)
["?[1]" \\parser]]]]]
@@ -17,12 +18,23 @@
(def sub
(maybe.trusted (i64.sub 32)))
-(`` (type .public I32
- (I64 (,, (|> (type_of ..sub)
- (?type.result (?type.applied (?.after (?type.exactly i64.Sub)
- ?type.any)))
- try.trusted
- (static.literal type.code))))))
+(for @.old
+ (def .public I32
+ Type
+ (when (type_of ..sub)
+ {.#Apply :size: :sub:}
+ (type_literal (I64 :size:))
+
+ _
+ (undefined)))
+
+ (`` (type .public I32
+ (I64 (,, (|> (type_of ..sub)
+ (?type.result (?type.applied (?.after (?type.exactly i64.Sub)
+ ?type.any)))
+ try.trusted
+ (static.literal type.code))))))
+ )
(def .public equivalence (Equivalence I32) (of ..sub sub_equivalence))
(def .public width Nat (of ..sub bits))
diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux
index fb1cb1912..6e91de08b 100644
--- a/stdlib/source/library/lux/math/number/int.lux
+++ b/stdlib/source/library/lux/math/number/int.lux
@@ -90,8 +90,7 @@
(def + ..+)
(def - ..-)
(def * ..*)
- (def / ../)
- (def % ..%)))
+ (def / ../)))
(def .public (/% param subject)
(-> Int Int
diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux
index d60d2c191..62b807133 100644
--- a/stdlib/source/library/lux/math/number/nat.lux
+++ b/stdlib/source/library/lux/math/number/nat.lux
@@ -125,8 +125,7 @@
(def + ..+)
(def - ..-)
(def * ..*)
- (def / ../)
- (def % ..%)))
+ (def / ../)))
(def .public (gcd a b)
(-> Nat Nat
diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux
index f24598300..4877d65da 100644
--- a/stdlib/source/library/lux/math/number/ratio.lux
+++ b/stdlib/source/library/lux/math/number/ratio.lux
@@ -144,8 +144,7 @@
(def + ..+)
(def - ..-)
(def * ..*)
- (def / ../)
- (def % ..%)))
+ (def / ../)))
(def .public (reciprocal (open "_[0]"))
(-> Ratio
diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux
index 16e8cc8f1..0cb32bf12 100644
--- a/stdlib/source/library/lux/math/number/rev.lux
+++ b/stdlib/source/library/lux/math/number/rev.lux
@@ -171,8 +171,7 @@
(def + ..+)
(def - ..-)
(def * ..*)
- (def / ../)
- (def % ..%)))
+ (def / ../)))
(with_template [<operator> <name>]
[(def .public (<name> scale subject)
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux
index 657ad6024..420daefdb 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/jvm.lux
@@ -69,6 +69,7 @@
["[0]" function
["[1]" abstract]]]]
["/[1]" //
+ ["[0]" phase (.use "[1]#[0]" monad)]
["[0]" translation]
["[0]" declaration]
["[1][0]" analysis (.only Analysis Operation Phase Handler Bundle)
@@ -78,7 +79,6 @@
["[0]A" type]
["[0]" scope]]
[///
- ["[0]" phase (.use "[1]#[0]" monad)]
["[0]" reference (.only)
["[0]" variable]]
[meta
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux
index 57a55392d..c99eb4832 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/jvm.lux
@@ -54,7 +54,6 @@
["[0]" descriptor (.only Descriptor)]
["[0]" parser]]]]
[compiler
- ["[0]" phase]
[reference
[variable (.only Register)]]
[meta
@@ -73,7 +72,7 @@
["[0]A" scope]]
["[0]" synthesis (.only Synthesis)
["<[1]>" \\parser]]
- [phase
+ ["[0]" phase (.only)
[translation
[jvm
["[0]" runtime (.only Anchor Definition Extender)]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux
index bfbe24cd2..770614d0c 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux
@@ -34,11 +34,11 @@
["//[1]" ///
["[0]" extension]
[//
+ ["[0]" phase (.use "[1]#[0]" monad)]
["[0]" synthesis (.only Synthesis)]
["[0]" translation]
[///
- ["[0]" reference]
- ["[0]" phase (.use "[1]#[0]" monad)]]]]])
+ ["[0]" reference]]]]])
(def (with_source_mapping @ it)
(All (_ of)
diff --git a/stdlib/source/library/lux/meta/compiler/meta/archive/key.lux b/stdlib/source/library/lux/meta/compiler/meta/archive/key.lux
index f23c094b4..e0c90d2a8 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/archive/key.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/archive/key.lux
@@ -11,10 +11,14 @@
Signature
(def .public signature
- (All (_ ?) (-> (Key ?) Signature))
+ (All (_ of)
+ (-> (Key of)
+ Signature))
(|>> representation))
(def .public (key signature sample)
- (All (_ d) (-> Signature d (Key d)))
+ (All (_ of)
+ (-> Signature of
+ (Key of)))
(abstraction signature))
)
diff --git a/stdlib/source/library/lux/world/finance/market/price.lux b/stdlib/source/library/lux/world/finance/market/price.lux
new file mode 100644
index 000000000..58c4216d8
--- /dev/null
+++ b/stdlib/source/library/lux/world/finance/market/price.lux
@@ -0,0 +1,151 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [equivalence (.only Equivalence)]
+ ["[0]" order (.only Order)]]
+ [data
+ [text
+ ["%" \\format]]]
+ [math
+ [number
+ ["i" int]]]
+ [meta
+ [type
+ ["[0]" nominal]]]]]
+ [///
+ [money (.only Money)
+ ["[0]" currency (.only Currency)]]])
+
+(type .public (Price $)
+ (Money $))
+
+... https://en.wikipedia.org/wiki/Price_action_trading
+(nominal.def .public (Action $)
+ (Record
+ [#currency (Currency $)
+ #movement Int])
+
+ (def .public (action currency movement)
+ (All (_ $)
+ (-> (Currency $) Int
+ (Action $)))
+ (nominal.abstraction
+ [#currency currency
+ #movement movement]))
+
+ (with_template [<*> <name>]
+ [(def .public (<name> currency it)
+ (All (_ $)
+ (-> (Currency $) Int
+ (Action $)))
+ (action currency
+ (<*> (.int (currency.sub_divisions currency))
+ it)))]
+
+ [i.* of_units]
+ [i.% of_sub_units]
+ )
+
+ (with_template [<name> <slot> <type>]
+ [(def .public <name>
+ (All (_ $)
+ (-> (Action $)
+ <type>))
+ (|>> nominal.representation
+ (the <slot>)))]
+
+ [currency #currency (Currency $)]
+ [movement #movement Int]
+ )
+
+ (def .public order
+ (All (_ $)
+ (Order (Action $)))
+ (of order.functor each
+ ..movement
+ i.order))
+
+ (def .public <
+ (All (_ $)
+ (-> (Action $) (Action $)
+ Bit))
+ (of ..order <))
+
+ (with_template [<name> <order>]
+ [(def .public <name>
+ (All (_ $)
+ (-> (Action $) (Action $)
+ Bit))
+ (<order> order))]
+
+ [<= order.<=]
+ [> order.>]
+ [>= order.>=]
+ )
+
+ (def .public equivalence
+ (All (_ $)
+ (Equivalence (Action $)))
+ (of ..order equivalence))
+
+ (def .public =
+ (All (_ $)
+ (-> (Action $) (Action $)
+ Bit))
+ (of ..equivalence =))
+
+ (with_template [<p> <i>]
+ [(def .public (<p> parameter subject)
+ (All (_ $)
+ (-> (Action $) (Action $)
+ (Action $)))
+ (let [parameter (nominal.representation parameter)
+ subject (nominal.representation subject)]
+ (nominal.abstraction
+ [#currency (the #currency subject)
+ #movement (<i> (the #movement parameter)
+ (the #movement subject))])))]
+
+ [+ i.+]
+ [- i.-]
+ )
+
+ (def .public (format it)
+ (All (_ $)
+ (%.Format (Action $)))
+ (let [[currency movement] (nominal.representation it)
+ [macro micro] (i./% (.int (currency.sub_divisions currency))
+ movement)]
+ (%.format (%.int macro)
+ (when micro
+ +0 ""
+ _ (%.format "." (%.nat (.nat micro))))
+ " " (currency.alphabetic_code currency))))
+ )
+
+(with_template [<order> <name>]
+ [(def .public (<name> left right)
+ (All (_ $)
+ (-> (Action $) (Action $)
+ (Action $)))
+ (if (<order> (..movement left)
+ (..movement right))
+ right
+ left))]
+
+ [i.< min]
+ [i.> max]
+ )
+
+(with_template [<*> <name>]
+ [(def .public (<name> it)
+ (All (_ $)
+ (-> (Action $)
+ Int))
+ (<*> (.int (currency.sub_divisions (..currency it)))
+ (..movement it)))]
+
+ [i./ units]
+ [i.% sub_units]
+ )
diff --git a/stdlib/source/library/lux/world/finance/money.lux b/stdlib/source/library/lux/world/finance/money.lux
index cd0724459..a32f05943 100644
--- a/stdlib/source/library/lux/world/finance/money.lux
+++ b/stdlib/source/library/lux/world/finance/money.lux
@@ -31,15 +31,18 @@
[#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 [<*> <name>]
+ [(def .public (<name> currency it)
+ (All (_ currency)
+ (-> (/.Currency currency) Nat
+ (Money currency)))
+ (money currency
+ (<*> (/.sub_divisions currency)
+ it)))]
+
+ [n.* of_units]
+ [n.% of_sub_units]
+ )
(with_template [<name> <slot> <type>]
[(def .public <name>
diff --git a/stdlib/source/library/lux/world/finance/trade/session.lux b/stdlib/source/library/lux/world/finance/trade/session.lux
index 821135300..e9e3d5f4c 100644
--- a/stdlib/source/library/lux/world/finance/trade/session.lux
+++ b/stdlib/source/library/lux/world/finance/trade/session.lux
@@ -11,10 +11,9 @@
["n" nat]]]]]
[///
["[0]" money (.only Money)
- [currency (.only Currency)]]])
-
-(type .public (Price $)
- (Money $))
+ [currency (.only Currency)]]
+ [market
+ [price (.only Price)]]])
(type .public Volume
Nat)