-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pro-functor lenses (part 4 of optics).
- Loading branch information
1 parent
2308e87
commit 3812076
Showing
6 changed files
with
259 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.using | ||
[library | ||
[lux (.except)]]) | ||
|
||
(every .public (Functor it) | ||
(Interface | ||
(is (for_any (_ cause effect | ||
cause' effect') | ||
(-> (-> cause' cause) (-> effect effect') | ||
(-> (it cause effect) | ||
(it cause' effect')))) | ||
each))) | ||
|
||
(every .public (Cartesian it) | ||
(Interface | ||
(is (for_any (_ cause effect extra) | ||
(-> (it cause effect) | ||
(it (And cause extra) (And effect extra)))) | ||
in_left) | ||
(is (for_any (_ cause effect extra) | ||
(-> (it cause effect) | ||
(it (And extra cause) (And extra effect)))) | ||
in_right))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
(.using | ||
[library | ||
[lux (.except) | ||
[abstract | ||
[equivalence (.only Equivalence)] | ||
[monad (.only do)]] | ||
["[0]" function] | ||
[math | ||
["[0]" random (.only Random)] | ||
[number | ||
["[0]" natural]]] | ||
[test | ||
["_" property (.only Test)]]]] | ||
[\\library | ||
["[0]" /]]) | ||
|
||
(every .public (Specification it) | ||
(-> it | ||
Test)) | ||
|
||
(the .public (specification concrete random | ||
functor) | ||
(for_any (_ it) | ||
(-> (-> (it Natural Natural) | ||
(-> Natural Natural)) | ||
(Random (it Natural Natural)) | ||
(Specification (/.Functor it)))) | ||
(<| (do [! random.monad] | ||
[cause random.natural | ||
it random]) | ||
(_.for [/.Functor]) | ||
(_.coverage [/.each] | ||
(let [it' (by functor each | ||
function.identity | ||
function.identity | ||
it) | ||
|
||
identity! | ||
(by natural.equivalence = | ||
((concrete it) cause) | ||
((concrete it') cause)) | ||
|
||
before_0 (is (Change Natural) | ||
++) | ||
before_1 (is (Change Natural) | ||
(natural.* 2)) | ||
|
||
after_0 (is (Change Natural) | ||
--) | ||
after_1 (is (Change Natural) | ||
(natural.* 3)) | ||
|
||
left | ||
(by functor each | ||
(|>> before_0 before_1) | ||
(|>> after_1 after_0) | ||
it) | ||
|
||
right | ||
(<| (by functor each | ||
before_0 | ||
after_0) | ||
(by functor each | ||
before_1 | ||
after_1) | ||
it) | ||
|
||
composite! | ||
(by natural.equivalence = | ||
((concrete left) cause) | ||
((concrete right) cause))] | ||
(and identity! | ||
composite!))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.