diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/source/lux.lux | 13 | ||||
-rw-r--r-- | stdlib/source/lux/concurrency/frp.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/concurrency/stm.lux | 20 | ||||
-rw-r--r-- | stdlib/source/lux/control/applicative.lux | 1 | ||||
-rw-r--r-- | stdlib/source/lux/control/pipe.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/data/coll/bits.lux | 5 | ||||
-rw-r--r-- | stdlib/source/lux/data/color.lux | 3 | ||||
-rw-r--r-- | stdlib/test/test/lux/lang/syntax.lux | 4 |
8 files changed, 27 insertions, 23 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 51e9af4dc..6e08c9cea 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -5112,6 +5112,9 @@ [deg-to-frac "lux deg to-frac" Deg Frac] ) +(def: #export frac-to-nat (|>> frac-to-int int-to-nat)) +(def: #export nat-to-frac (|>> nat-to-int int-to-frac)) + (def: (repeat n x) (All [a] (-> Int a (List a))) (if (i/> 0 n) @@ -6067,3 +6070,13 @@ (let [shift (if (i/< 0 param) i/- i/+)] (|> raw (shift param))) raw))) + +(do-template [<type> </%> </> <%>] + [(def: #export (</%> param subject) + (-> <type> <type> [<type> <type>]) + [(</> param subject) + (<%> param subject)])] + + [Nat n//% n// n/%] + [Int i//% i// i/%] + ) diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux index e7efcbf3d..fbe55efee 100644 --- a/stdlib/source/lux/concurrency/frp.lux +++ b/stdlib/source/lux/concurrency/frp.lux @@ -74,7 +74,7 @@ output))) (def: #export (periodic time) - (All [a] (-> Nat (Channel a))) + (-> Nat (Channel Unit)) (let [output (channel [])] (exec (io.run (loop [_ []] diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index cc609a055..4e2d82905 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -43,17 +43,19 @@ (wrap [])) (write! new-value (@abstraction var))))) - (def: #export (follow (^@representation target)) + (def: (helper|follow var) + (All [a] (-> (Var a) (frp.Channel a))) + (frp.channel [])) + (def: #export (follow target) {#.doc "Creates a channel that will receive all changes to the value of the given var."} (All [a] (-> (Var a) (IO (frp.Channel a)))) - (let [channel (: (frp.Channel ($ +0)) (frp.channel [])) - ## channel (frp.channel) - ] - (do io.Monad<IO> - [_ (atom.update (function [[value observers]] - [value (#.Cons (frp.publish channel) observers)]) - target)] - (wrap channel)))) + (do io.Monad<IO> + [#let [channel (helper|follow target) + target (@representation target)] + _ (atom.update (function [[value observers]] + [value (#.Cons (frp.publish channel) observers)]) + target)] + (wrap channel))) ) (type: (Tx-Frame a) diff --git a/stdlib/source/lux/control/applicative.lux b/stdlib/source/lux/control/applicative.lux index 54cef5c45..a827a06d3 100644 --- a/stdlib/source/lux/control/applicative.lux +++ b/stdlib/source/lux/control/applicative.lux @@ -22,6 +22,7 @@ (def: wrap (|>> (:: Applicative<G> wrap) (:: Applicative<F> wrap))) (def: (apply fgf fgx) + ## TODO: Switch from this version to the one below (in comments) ASAP. (let [fgf' (:: Applicative<F> apply (:: Applicative<F> wrap (:: Applicative<G> apply)) fgf)] diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux index b70ec8f8a..a2d6ba5fc 100644 --- a/stdlib/source/lux/control/pipe.lux +++ b/stdlib/source/lux/control/pipe.lux @@ -43,7 +43,7 @@ prev [else body^] [_ _reverse_] - [branches (p.many (p.seq body^ body^))]) + [branches (p.some (p.seq body^ body^))]) {#.doc (doc "Branching for pipes." "Both the tests and the bodies are piped-code, and must be given inside a tuple." (|> 5 diff --git a/stdlib/source/lux/data/coll/bits.lux b/stdlib/source/lux/data/coll/bits.lux index e7a407b1c..64d404c1a 100644 --- a/stdlib/source/lux/data/coll/bits.lux +++ b/stdlib/source/lux/data/coll/bits.lux @@ -16,11 +16,6 @@ (def: empty-chunk Chunk +0) -(def: (n//% param subject) - (-> Nat Nat [Nat Nat]) - [(n// param subject) - (n/% param subject)]) - (def: #export empty Bits (array.new +0)) diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index 899531a79..081d94674 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -8,9 +8,6 @@ (def: rgb Nat +256) (def: top Nat (n/dec rgb)) -(def: nat-to-frac (-> Nat Frac) (|>> nat-to-int int-to-frac)) -(def: frac-to-nat (-> Frac Nat) (|>> frac-to-int int-to-nat)) - (def: rgb-factor Frac (nat-to-frac top)) (def: scale-down diff --git a/stdlib/test/test/lux/lang/syntax.lux b/stdlib/test/test/lux/lang/syntax.lux index eaba58d0f..a12aa5ae9 100644 --- a/stdlib/test/test/lux/lang/syntax.lux +++ b/stdlib/test/test/lux/lang/syntax.lux @@ -107,10 +107,6 @@ (:: code.Eq<Code> = other =other))))) )))) -(def: nat-to-frac - (-> Nat Frac) - (|>> nat-to-int int-to-frac)) - (context: "Frac special syntax." (<| (times +100) (do @ |