Skip to content

Commit

Permalink
Simplified experimental pattern-matching code a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Aug 13, 2023
1 parent 51116cd commit 0e581d6
Show file tree
Hide file tree
Showing 40 changed files with 478 additions and 483 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@

($.definition /.adapter
""
($.example (' (adapter reference subject))))
($.example (' (adapter expected actual))))
))
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/math/modulus.lux
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

($.definition /.congruent?
""
($.example (' (congruent? modulus reference subject))))
($.example (' (congruent? modulus expected actual))))

($.definition /.literal
""
Expand Down
58 changes: 29 additions & 29 deletions stdlib/source/library/lux/control/logic.lux
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@
(Logic of)))
(object.on #value [] it))

(the .public (= reference subject)
(the .public (= expected actual)
(All (_ of)
(-> (Term of) ((Term of) Any)
(Logic Any)))
(object.on #unified [reference] subject))
(object.on #unified [expected] actual))

(every (Constant of)
[(Equivalence of) of])
Expand All @@ -156,17 +156,17 @@
(let [[this#= this_value] (object.state this)]
(of ..monad in this_value))))
#unified (object.method
(function (_ next again [this [reference]])
(when (object.as (object.class this) reference)
{.#Some reference}
(let [[reference#= reference_value] (object.state reference)
(function (_ next again [this [expected]])
(when (object.as (object.class this) expected)
{.#Some expected}
(let [[expected#= expected_value] (object.state expected)
[this#= this_value] (object.state this)]
(if (this#= reference_value this_value)
(if (this#= expected_value this_value)
..success
..failure))

{.#None}
(= this reference))))])
(= this expected))))])

(the .public (constant equivalence it)
(All (_ of)
Expand Down Expand Up @@ -245,7 +245,7 @@
_
(try#in context)))

(the (unified_variables reference_id this)
(the (unified_variables expected_id this)
(All (_ of)
(-> (Variable of) ((Term of) (Variable of))
(Logic Any)))
Expand All @@ -254,35 +254,35 @@
(<| (try.else (list))
(is (Try (List [Context Any])))
(do [! try.monad]
[[reference#= reference_value] (binding reference_id context)
[[expected#= expected_value] (binding expected_id context)
[this#= this_value] (binding this_id context)]
(when [reference_value this_value]
[{.#Right reference_value}
(when [expected_value this_value]
[{.#Right expected_value}
{.#Right this_value}]
(in (if (of this#= = reference_value this_value)
(in (if (of this#= = expected_value this_value)
(list [context this_value])
(list)))

[{.#Right reference_value}
[{.#Right expected_value}
{.#Left this_link}]
(do !
[ring (..ring this_link context)]
(in (list [(list#mix (has_binding this#= reference_value) context ring)
(in (list [(list#mix (has_binding this#= expected_value) context ring)
[]])))

[{.#Left reference_link}
[{.#Left expected_link}
{.#Right this_value}]
(do !
[ring (..ring reference_link context)]
(in (list [(list#mix (has_binding reference#= this_value) context ring)
[ring (..ring expected_link context)]
(in (list [(list#mix (has_binding expected#= this_value) context ring)
[]])))

[{.#Left reference_link}
[{.#Left expected_link}
{.#Left this_link}]
(do !
[this_ring (..ring this_link context)
reference_ring (..ring reference_link context)
context (connected this_ring reference_ring context)]
expected_ring (..ring expected_link context)
context (connected this_ring expected_ring context)]
(in (list [context []])))))))))

(the variable_class
Expand All @@ -299,15 +299,15 @@
_
(list)))))
#unified (object.method
(function (_ next again [this [reference]])
(when (object.as (object.class this) reference)
{.#Some reference}
(let [reference_id (object.state reference)]
(unified_variables reference_id this))
(function (_ next again [this [expected]])
(when (object.as (object.class this) expected)
{.#Some expected}
(let [expected_id (object.state expected)]
(unified_variables expected_id this))

{.#None}
(do ..monad
[reference_value (..value reference)]
[expected_value (..value expected)]
(function (_ context)
(let [id (object.state this)]
(<| (try.else (list))
Expand All @@ -316,13 +316,13 @@
[[this#= this_value] (binding id context)]
(in (when this_value
{.#Right this_value}
(if (of this#= = reference_value this_value)
(if (of this#= = expected_value this_value)
(list [context this_value])
(list))

{.#Left link}
(list [(dictionary.has (nominal.representation id)
[this#= {.#Right reference_value}]
[this#= {.#Right expected_value}]
context)
[]])))))))))))])

Expand Down
Loading

0 comments on commit 0e581d6

Please sign in to comment.