Skip to content

Commit

Permalink
Polytypic programming based on induction, instead of parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Aug 15, 2023
1 parent caab080 commit 9b6682b
Show file tree
Hide file tree
Showing 60 changed files with 795 additions and 771 deletions.
3 changes: 3 additions & 0 deletions documentation/bookmark/health.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Reference

0. [Young blood transfusion](https://en.wikipedia.org/wiki/Young_blood_transfusion)
* [EXCLUSIVE: Ambrosia, the Young Blood Transfusion Startup, Is Quietly Back in Business](https://onezero.medium.com/exclusive-ambrosia-the-young-blood-transfusion-startup-is-quietly-back-in-business-ee2b7494b417)
* [El tratamiento controversial](https://www.youtube.com/watch?v=oksvKi1n3ts)
0. [From Worst-Case CANCER to Best-Case Scenario (NO CANCER)](https://www.youtube.com/watch?v=6JD_JzprK5U)
0. [How To Naturally Reverse Premature Graying of Hair](https://www.youtube.com/watch?v=LMLdClbwqhE)
0. [Contraceptive Properties of Stevia rebaudiana](https://www.science.org/doi/10.1126/science.162.3857.1007.a)
Expand Down
3 changes: 0 additions & 3 deletions lux-mode/lux-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ Called by `imenu--generic-function'."
"Class"
"type"))
(type//checking (altRE "is" "as" "let" "as_expected" "type_of" "sharing" "by_example" "hole"))
(type//poly (altRE "polytypic"))
(type//dynamic (altRE "dynamic" "static"))
(type//capability (altRE "capability"))
;; Data
Expand Down Expand Up @@ -409,7 +408,6 @@ Called by `imenu--generic-function'."
control//polymorphism))
(type (altRE type//syntax
type//checking
type//poly
type//dynamic
type//capability))
(data (altRE data//record
Expand Down Expand Up @@ -583,7 +581,6 @@ This function also returns nil meaning don't specify the indentation."
("macro" 'defun)
("syntax" 'defun)
("template" 'defun)
("polytypic" 'defun)
("program" 'defun)

("the" 'defun)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/data/collection/bits.lux
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

($.definition /.intersects?
""
($.example (' (intersects? reference sample))))
($.example (' (intersects? reference it))))

($.definition /.not
""
Expand Down
10 changes: 5 additions & 5 deletions stdlib/source/documentation/lux/math/number/frac.lux
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,23 @@

($.definition /.=
"Frac(tion) equivalence."
($.example (' (= reference sample))))
($.example (' (= expected actual))))

($.definition /.<
"Frac(tion) less-than."
($.example (' (< reference sample))))
($.example (' (< reference it))))

($.definition /.<=
"Frac(tion) less-than or equal."
($.example (' (<= reference sample))))
($.example (' (<= reference it))))

($.definition /.>
"Frac(tion) greater-than."
($.example (' (> reference sample))))
($.example (' (> reference it))))

($.definition /.>=
"Frac(tion) greater-than or equal."
($.example (' (>= reference sample))))
($.example (' (>= reference it))))

(,, (with_template [<name> <doc>]
[($.definition <name>
Expand Down
10 changes: 5 additions & 5 deletions stdlib/source/documentation/lux/math/number/int.lux
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@

($.definition /.=
"Int(eger) equivalence."
($.example (' (= reference sample))))
($.example (' (= expected actual))))

($.definition /.<
"Int(eger) less-than."
($.example (' (< reference sample))))
($.example (' (< reference it))))

($.definition /.<=
"Int(eger) less-than or equal."
($.example (' (<= reference sample))))
($.example (' (<= reference it))))

($.definition /.>
"Int(eger) greater-than."
($.example (' (> reference sample))))
($.example (' (> reference it))))

($.definition /.>=
"Int(eger) greater-than or equal."
($.example (' (>= reference sample))))
($.example (' (>= reference it))))

(,, (with_template [<name> <doc>]
[($.definition <name>
Expand Down
10 changes: 5 additions & 5 deletions stdlib/source/documentation/lux/math/number/rev.lux
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@

($.definition /.=
"Rev(olution) equivalence."
($.example (' (= reference sample))))
($.example (' (= expected actual))))

($.definition /.<
"Rev(olution) less-than."
($.example (' (< reference sample))))
($.example (' (< reference it))))

($.definition /.<=
"Rev(olution) less-than or equal."
($.example (' (<= reference sample))))
($.example (' (<= reference it))))

($.definition /.>
"Rev(olution) greater-than."
($.example (' (> reference sample))))
($.example (' (> reference it))))

($.definition /.>=
"Rev(olution) greater-than or equal."
($.example (' (>= reference sample))))
($.example (' (>= reference it))))

(,, (with_template [<name> <doc>]
[($.definition <name>
Expand Down
24 changes: 12 additions & 12 deletions stdlib/source/library/lux.lux
Original file line number Diff line number Diff line change
Expand Up @@ -1226,9 +1226,9 @@
{#End}}
[xs ys]))

(def' .private (text#= reference sample)
(def' .private (text#= expected actual)
{#Function Text {#Function Text Bit}}
(.text_=# reference sample))
(.text_=# expected actual))

(def' .private (replacement for environment)
{#Function Text {#Function Replacement_Environment ($ Maybe Code)}}
Expand Down Expand Up @@ -2640,16 +2640,16 @@
I64)
(.i64_and# low_mask value))

(def' .private (n#< reference sample)
(def' .private (n#< reference it)
(-> Nat Nat
Bit)
(let' [referenceH (high_bits reference)
sampleH (high_bits sample)]
(if (.int_<# referenceH sampleH)
itH (high_bits it)]
(if (.int_<# referenceH itH)
#1
(if (.i64_=# referenceH sampleH)
(if (.i64_=# referenceH itH)
(.int_<# (low_bits reference)
(low_bits sample))
(low_bits it))
#0))))

(def' .private (list#conjoint xs)
Expand Down Expand Up @@ -4568,12 +4568,12 @@
[(.text_clip# 0 at x)
(.text_clip# at (|> x .text_size# (.i64_-# at)) x)])

(the (text#split_by token sample)
(the (text#split_by token it)
(-> Text Text
(Maybe [Text Text]))
(do ..maybe#monad
[index (..index token sample)
.let [[pre post'] (text#split_at' index sample)
[index (..index token it)
.let [[pre post'] (text#split_at' index it)
[_ post] (text#split_at' (.text_size# token) post')]]
(in [pre post])))

Expand Down Expand Up @@ -5752,11 +5752,11 @@
{#None}
(failure ..wrong_syntax)))))

(the .public (same? reference sample)
(the .public (same? expected actual)
(All (_ of)
(-> of of
Bit))
(.is?# reference sample))
(.is?# expected actual))

(the .public as_expected
(macro (_ tokens)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/library/lux/abstract/equivalence.lux
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
(implementation
(the (each value it)
(implementation
(the (= reference sample)
(of it = (value reference) (value sample)))))))
(the (= expected actual)
(of it = (value expected) (value actual)))))))

(the .public (sum left right)
(All (_ left right)
Expand Down
8 changes: 4 additions & 4 deletions stdlib/source/library/lux/abstract/functor/contravariant.lux
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
[library
[lux (.except)]])

(every .public (Functor f)
(every .public (Functor !)
(Interface
(is (All (_ a b)
(-> (-> b a)
(-> (f a) (f b))))
(is (All (_ a z)
(-> (-> z a)
(-> (! a) (! z))))
each)))
86 changes: 43 additions & 43 deletions stdlib/source/library/lux/abstract/interval.lux
Original file line number Diff line number Diff line change
Expand Up @@ -97,49 +97,49 @@
(the bottom (of interval succ (of interval top)))
(the top (of interval pred (of interval bottom)))))

(the .public (precedes? reference sample)
(the .public (precedes? reference it)
(All (_ a) (-> (Interval a) (Interval a) Bit))
(let [(open "[0]") reference
limit (of reference bottom)]
(and (< limit (of sample bottom))
(< limit (of sample top)))))
(and (< limit (of it bottom))
(< limit (of it top)))))

(the .public (succeeds? reference sample)
(the .public (succeeds? reference it)
(All (_ a) (-> (Interval a) (Interval a) Bit))
(precedes? sample reference))
(precedes? it reference))

(with_template [<name> <comp>]
[(the .public (<name> reference sample)
[(the .public (<name> reference it)
(All (_ a) (-> a (Interval a) Bit))
(let [(open ",#[0]") sample]
(let [(open ",#[0]") it]
(and (<comp> reference ,#bottom)
(<comp> reference ,#top))))]

[before? ,#<]
[after? (order.> ,#order)]
)

(the .public (meets? reference sample)
(the .public (meets? reference it)
(All (_ a) (-> (Interval a) (Interval a) Bit))
(let [(open ",#[0]") reference
limit (of reference bottom)]
(and (,#= limit (of sample top))
(order.<= ,#order limit (of sample bottom)))))
(and (,#= limit (of it top))
(order.<= ,#order limit (of it bottom)))))

(the .public (touches? reference sample)
(the .public (touches? reference it)
(All (_ a) (-> (Interval a) (Interval a) Bit))
(or (meets? reference sample)
(meets? sample reference)))
(or (meets? reference it)
(meets? it reference)))

(with_template [<name> <eq_side> <ineq> <ineq_side>]
[(the .public (<name> reference sample)
[(the .public (<name> reference it)
(All (_ a) (-> (Interval a) (Interval a) Bit))
(let [(open ",#[0]") reference]
(and (,#= (of reference <eq_side>)
(of sample <eq_side>))
(of it <eq_side>))
(<ineq> ,#order
(of reference <ineq_side>)
(of sample <ineq_side>)))))]
(of it <ineq_side>)))))]

[starts? ,#bottom order.<= ,#top]
[finishes? ,#top order.>= ,#bottom]
Expand All @@ -148,51 +148,51 @@
(the .public equivalence
(All (_ a) (Equivalence (Interval a)))
(implementation
(the (= reference sample)
(let [(open ",#[0]") reference]
(and (,#= ,#bottom (of sample bottom))
(,#= ,#top (of sample top)))))))
(the (= expected actual)
(let [(open ",#[0]") expected]
(and (,#= ,#bottom (of actual bottom))
(,#= ,#top (of actual top)))))))

(the .public (nested? reference sample)
(the .public (nested? reference it)
(All (_ a) (-> (Interval a) (Interval a) Bit))
(cond (or (singleton? sample)
(and (inner? reference) (inner? sample))
(and (outer? reference) (outer? sample)))
(cond (or (singleton? it)
(and (inner? reference) (inner? it))
(and (outer? reference) (outer? it)))
(let [(open ",#[0]") reference]
(and (order.>= ,#order (of reference bottom) (of sample bottom))
(order.<= ,#order (of reference top) (of sample top))))
(and (order.>= ,#order (of reference bottom) (of it bottom))
(order.<= ,#order (of reference top) (of it top))))

(or (singleton? reference)
(and (inner? reference) (outer? sample)))
(and (inner? reference) (outer? it)))
false

... (and (outer? reference) (inner? sample))
... (and (outer? reference) (inner? it))
(let [(open ",#[0]") reference]
(or (and (order.>= ,#order (of reference bottom) (of sample bottom))
(order.> ,#order (of reference bottom) (of sample top)))
(and (,#< (of reference top) (of sample bottom))
(order.<= ,#order (of reference top) (of sample top)))))
(or (and (order.>= ,#order (of reference bottom) (of it bottom))
(order.> ,#order (of reference bottom) (of it top)))
(and (,#< (of reference top) (of it bottom))
(order.<= ,#order (of reference top) (of it top)))))
))

(the .public (overlaps? reference sample)
(the .public (overlaps? reference it)
(All (_ a) (-> (Interval a) (Interval a) Bit))
(let [(open ",#[0]") reference]
(and (not (of ..equivalence = reference sample))
(cond (singleton? sample)
(and (not (of ..equivalence = reference it))
(cond (singleton? it)
false

(singleton? reference)
(nested? sample reference)
(nested? it reference)

(or (and (inner? sample) (outer? reference))
(and (outer? sample) (inner? reference)))
(or (order.>= ,#order (of reference bottom) (of sample top))
(order.<= ,#order (of reference top) (of sample bottom)))
(or (and (inner? it) (outer? reference))
(and (outer? it) (inner? reference)))
(or (order.>= ,#order (of reference bottom) (of it top))
(order.<= ,#order (of reference top) (of it bottom)))

... both inner
(inner? sample)
(inner? (intersection reference sample))
(inner? it)
(inner? (intersection reference it))

... both outer
(not (nested? reference sample))
(not (nested? reference it))
))))
Loading

0 comments on commit 9b6682b

Please sign in to comment.