-
-
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 member/traversal (part 8 of optics).
- Loading branch information
1 parent
58f497c
commit da7eade
Showing
11 changed files
with
348 additions
and
152 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
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 |
---|---|---|
@@ -1,105 +1,11 @@ | ||
... 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/. | ||
|
||
... [Profunctor Optics: Modular Data Accessors](https://arxiv.org/abs/1703.10857) | ||
(.using | ||
[library | ||
[lux (.except all with) | ||
[abstract | ||
[functor (.only Functor) | ||
["[0]" pro]]] | ||
[type | ||
["[0]" nominal]] | ||
["[0]" function] | ||
[data | ||
["[0]" product]]]]) | ||
[lux (.except)]]) | ||
|
||
(every .public (Aspect it context context' aspect aspect') | ||
(-> (it aspect aspect') | ||
(it context context'))) | ||
|
||
... TODO: Make this nominal type unnecessary. | ||
(nominal.every .public (Membership one all) | ||
(Variant | ||
{#All all} | ||
{#One one (Membership one (-> one all))}) | ||
|
||
(the outer | ||
(for_any (_ one all) | ||
(-> (Membership one all) | ||
(Or all (And one (Membership one (-> one all)))))) | ||
(|>> nominal.as)) | ||
|
||
(the inner | ||
(for_any (_ one all) | ||
(-> (Or all (And one (Membership one (-> one all)))) | ||
(Membership one all))) | ||
(|>> nominal.of)) | ||
|
||
(the .public membership_functor | ||
(for_any (_ one) | ||
(Functor (Membership one))) | ||
(implementation | ||
(the (each value it) | ||
(nominal.of | ||
(.when (nominal.as it) | ||
{#All all} | ||
{#All (value all)} | ||
|
||
{#One one next} | ||
{#One one (each (function (_ before) | ||
(|>> before | ||
value)) | ||
next)})) | ||
))) | ||
|
||
(every .public (Apply context) | ||
(Interface | ||
(is (Functor context) | ||
functor) | ||
(is (for_any (_ it) | ||
(-> it | ||
(context it))) | ||
pure) | ||
(is (for_any (_ it it') | ||
(-> (context (-> it it')) | ||
(-> (context it) | ||
(context it')))) | ||
with))) | ||
|
||
(the .public membership_apply | ||
(for_any (_ one) | ||
(Apply (Membership one))) | ||
(implementation | ||
(the functor ..membership_functor) | ||
(the pure (|>> {#All} nominal.of)) | ||
(the (with internal_effect internal_cause) | ||
(.when (nominal.as internal_effect) | ||
{#All internal_effect} | ||
(by ..membership_functor each internal_effect internal_cause) | ||
|
||
{#One one internal_effect} | ||
(nominal.of | ||
{#One one (with (by ..membership_functor each function.flipped internal_effect) | ||
internal_cause)}))))) | ||
|
||
(the .public (one it) | ||
(for_any (_ it) | ||
(-> it | ||
(Membership it it))) | ||
(nominal.of {#One it (nominal.of {#All (|>>)})})) | ||
|
||
(the .public (all it) | ||
(for_any (_ one all) | ||
(-> (Membership one all) | ||
all)) | ||
(.when (nominal.as it) | ||
{#All it} | ||
it | ||
|
||
{#One one next} | ||
((all next) one))) | ||
|
||
(every .public (Member all one) | ||
(-> all | ||
(Membership one all))) | ||
) | ||
(every .public (Aspect => context context' aspect aspect') | ||
(-> (=> aspect aspect') | ||
(=> context context'))) |
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.