Skip to content

Commit

Permalink
Re-named Ratio to Frac.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Aug 20, 2023
1 parent 9291b0f commit 7c144b9
Show file tree
Hide file tree
Showing 40 changed files with 1,020 additions and 873 deletions.
2 changes: 0 additions & 2 deletions stdlib/source/documentation/lux/abstract.lux
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
["[1][0]" comonad]
["[1][0]" enum]
["[1][0]" equivalence]
["[1][0]" mix]
["[1][0]" functor]
["[1][0]" hash]
["[1][0]" interval]
Expand All @@ -30,7 +29,6 @@
/comonad.documentation
/enum.documentation
/equivalence.documentation
/mix.documentation
/functor.documentation
/hash.documentation
/interval.documentation
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/documentation/lux/math/number.lux
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
["[1][0]" int]
["[1][0]" rev]
["[1][0]" dec]
["[1][0]" ratio]
["[1][0]" frac]
["[1][0]" complex]])

(`` (the .public documentation
Expand Down Expand Up @@ -51,7 +51,7 @@
/int.documentation
/rev.documentation
/dec.documentation
/ratio.documentation
/frac.documentation
/complex.documentation
)
)))
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(the .public documentation
(List $.Documentation)
(list ($.module /._
"Rational numbers.")
"Fractions.")

($.definition /.nat)
($.definition /.=)
Expand All @@ -34,13 +34,13 @@
($.definition /.addition)
($.definition /.multiplication)

($.definition /.Ratio
($.definition /.Frac
"An unsigned ratio of numbers.")

($.definition /.ratio
"Rational literals."
($.example (' (ratio numerator denominator)))
($.definition /.frac
"Fraction literals."
($.example (' (frac numerator denominator)))

($.comment "The denominator can be omitted if it is 1.")
($.example (' (ratio numerator))))
($.example (' (frac numerator))))
))
6 changes: 3 additions & 3 deletions stdlib/source/documentation/lux/meta/type/unit.lux
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
["%" \\format (.only format)]]]
[math
[number
["[0]" ratio]]]
["[0]" frac]]]
[meta
[macro
["[0]" template]]]]]
Expand Down Expand Up @@ -69,8 +69,8 @@

... (,, (with_template [<type> <scale>]
... [(`` ($.definition <scale>
... (let [numerator (its [/.ratio ratio.#numerator] <scale>)
... denominator (its [/.ratio ratio.#denominator] <scale>)]
... (let [numerator (its [/.frac frac.#numerator] <scale>)
... denominator (its [/.frac frac.#denominator] <scale>)]
... (format "The '" (,, (template.text [<scale>])) "' scale, from " (%.nat numerator) " to " (%.nat denominator) "."))))]

... [/.Kilo /.kilo]
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/format/lux/data/text.lux
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
["[0]" int]
["[0]" rev]
["[0]" dec]
["[0]" ratio]
["[0]" frac]
["[0]" complex]]
[arithmetic
["[0]" modular]]]
Expand Down Expand Up @@ -72,7 +72,7 @@
[dec Dec (of dec.decimal encoded)]
[text Text text.format]

[ratio ratio.Ratio (of ratio.codec encoded)]
[frac frac.Frac (of frac.codec encoded)]
[complex complex.Complex complex.format]

[symbol Symbol (of symbol.absolute encoded)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
(.require
[library
[lux (.except)
["//" algorithm]]]
[//
[monoid (.only Monoid)]])
[abstract
[monoid (.only Monoid)]]]]
["[0]" //])

(every .public (Mix !)
(Interface
Expand Down
94 changes: 58 additions & 36 deletions stdlib/source/library/lux/control/concurrency/actor.lux
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@
(exception.the .public poisoned)
(exception.the .public dead)

(local.let [<Mail> (template (_ Actor s)
[(-> s (Actor s) (Async (Try s)))])
<Obituary> (template (_ Actor s)
[[Text s (List (<Mail> Actor s))]])
<Mailbox> (template (_ Actor s)
(local.let [<Mail> (template (_ Actor state)
[(-> state (Actor state)
(Async (Try state)))])
<Obituary> (template (_ Actor state)
[[Text state (List (<Mail> Actor state))]])
<Mailbox> (template (_ Actor state)
[(Rec Mailbox
[(Async [(<Mail> Actor s) Mailbox])
(Resolver [(<Mail> Actor s) Mailbox])])])]
[(Async [(<Mail> Actor state) Mailbox])
(Resolver [(<Mail> Actor state) Mailbox])])])]
(these (the (pending [read write])
(All (_ a)
(All (_ of)
(-> (Rec Mailbox
[(Async [a Mailbox])
(Resolver [a Mailbox])])
(IO (List a))))
[(Async [of Mailbox])
(Resolver [of Mailbox])])
(IO (List of))))
(do [! io.monad]
[current (async.value read)]
(when current
Expand All @@ -53,23 +54,26 @@
{.#None}
(in {.#End}))))

(nominal.every .public (Actor s)
(nominal.every .public (Actor state)
(Record
[#obituary [(Async (<Obituary> Actor s))
(Resolver (<Obituary> Actor s))]
#mailbox (Atom (<Mailbox> Actor s))])
[#obituary [(Async (<Obituary> Actor state))
(Resolver (<Obituary> Actor state))]
#mailbox (Atom (<Mailbox> Actor state))])

(every .public (Mail s)
(<Mail> Actor s))
(every .public (Mail state)
(<Mail> Actor state))

(every .public (Obituary s)
(<Obituary> Actor s))
(every .public (Obituary state)
(<Obituary> Actor state))

(every .public (Behavior s)
(-> (Mail s) s (Actor s) (Async (Try s))))
(every .public (Behavior state)
(-> (Mail state) state (Actor state)
(Async (Try state))))

(the .public (spawn! behavior init)
(All (_ s) (-> (Behavior s) s (IO (Actor s))))
(All (_ state)
(-> (Behavior state) state
(IO (Actor state))))
(io (let [self (`` (is (Actor (,, (type_of init)))
(nominal.abstraction
[#obituary (async.async [])
Expand All @@ -94,7 +98,9 @@
self)))

(the .public (alive? actor)
(All (_ s) (-> (Actor s) (IO Bit)))
(All (_ state)
(-> (Actor state)
(IO Bit)))
(let [[obituary _] (its #obituary (nominal.representation actor))]
(|> obituary
async.value
Expand All @@ -107,18 +113,24 @@
bit.no))))))

(the .public (obituary' actor)
(All (_ s) (-> (Actor s) (IO (Maybe (Obituary s)))))
(All (_ state)
(-> (Actor state)
(IO (Maybe (Obituary state)))))
(let [[obituary _] (its #obituary (nominal.representation actor))]
(async.value obituary)))

(the .public obituary
(All (_ s) (-> (Actor s) (Async (Obituary s))))
(All (_ state)
(-> (Actor state)
(Async (Obituary state))))
(|>> nominal.representation
(its #obituary)
product.left))

(the .public (mail! mail actor)
(All (_ s) (-> (Mail s) (Actor s) (IO (Try Any))))
(All (_ state)
(-> (Mail state) (Actor state)
(IO (Try Any))))
(do [! io.monad]
[alive? (..alive? actor)]
(if alive?
Expand All @@ -142,16 +154,20 @@
(again |mailbox|'))))))
(in (exception.except ..dead [])))))

(every .public (Message s o)
(-> s (Actor s) (Async (Try [s o]))))
(every .public (Message state of)
(-> state (Actor state)
(Async (Try [state of]))))

(the (mail message)
(All (_ s o) (-> (Message s o) [(Async (Try o)) (Mail s)]))
(let [[async resolve] (sharing [s o]
(is (Message s o)
(All (_ state of)
(-> (Message state of)
[(Async (Try of))
(Mail state)]))
(let [[async resolve] (sharing [state of]
(is (Message state of)
message)
(is [(Async (Try o))
(Resolver (Try o))]
(is [(Async (Try of))
(Resolver (Try of))]
(async.async [])))]
[async
(function (_ state self)
Expand All @@ -169,7 +185,9 @@
(async.resolved {try.#Failure error})))))]))

(the .public (request! message actor)
(All (_ s o) (-> (Message s o) (Actor s) (Async (Try o))))
(All (_ state of)
(-> (Message state of) (Actor state)
(Async (Try of))))
(let [[async mail] (..mail message)]
(do async.monad
[outcome (async.future (..mail! mail actor))]
Expand All @@ -187,7 +205,9 @@
(mail state self)))

(the .public (poison! actor)
(All (_ s) (-> (Actor s) (IO (Try Any))))
(All (_ state)
(-> (Actor state)
(IO (Try Any))))
(..mail! (function (_ state self)
(async.resolved (exception.except ..poisoned [])))
actor))
Expand All @@ -199,7 +219,9 @@
(the stop! false)

(the .public (observe! action channel actor)
(All (_ r w s) (-> (-> r Stop (Mail s)) (Channel' r w) (Actor s) (IO Any)))
(All (_ read write state)
(-> (-> read Stop (Mail state)) (Channel' read write) (Actor state)
(IO Any)))
(let [signal (is (Atom Bit)
(atom.atom ..continue!))
stop (is Stop
Expand Down
3 changes: 2 additions & 1 deletion stdlib/source/library/lux/data/collection/array.lux
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[abstract
[monoid (.only Monoid)]
[functor (.only Functor)]
[equivalence (.only Equivalence)]
[equivalence (.only Equivalence)]]
[algorithm
[mix (.only Mix)]]
[control
["[0]" try (.only Try)]
Expand Down

0 comments on commit 7c144b9

Please sign in to comment.