Created
February 25, 2017 21:32
-
-
Save xaviervia/f63a093aa87e0e069d8449793d16271c to your computer and use it in GitHub Desktop.
2017-02-25
This file contains hidden or 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
Graph : | |
(Cell (->) a b) -> | |
(Cell (->) b c) -> | |
Either (a, Either (b, c)) -> | |
Either (a, Either (b, c)) | |
Left.of(a, Left.of(b, c)) | |
A B | |
Right.of([A, either(first)(first)(B)]) | |
g = Graph(add1)(mul3) | |
Graph( | |
Right.of([ | |
1, | |
Left.of([2, 6]) | |
]) | |
) | |
h = Graph(add100, g) | |
h( | |
Right.of([ | |
1, | |
Right.of([ | |
100, | |
Left.of([ | |
101, | |
Left.of([ | |
102, Left.of(306)]) | |
]) | |
]) | |
]) | |
) | |
--- | |
Cell -> List ChainCell -> Either (a, List Either b) | |
--- | |
Cell : (a -> b) -> Either (a, b) -> Either (a, b) | |
Effect = f (State) BUT | |
State = PrevState & Diff / NextState | |
Effect | |
// const add1Cell = Cell( add(1) ) | |
// const multiply2Cell = Cell( multiply(2) ) | |
// | |
// add1Cell.compose(multiply2Cell)(Right([1, 2])) => Right([2, 3]) | |
Graph([ | |
Right.of([1, null]), | |
[ | |
[ | |
Right.of([null, null]), | |
[ | |
Right.of([null, null]) | |
Right.of([null, null]) | |
] | |
], | |
Right.of([null, null]) | |
] | |
]) | |
// => | |
Left.of([ | |
[1, null], | |
[ | |
[ | |
[2, null], | |
[ | |
[5, null], | |
[5, null] | |
] | |
], | |
[2, null] | |
] | |
]) | |
Right.of([ | |
[1, 2], | |
[ | |
Right.of([ | |
[2, null], | |
[ | |
Left.of([5, null]), | |
Left.of([5, null]) | |
] | |
]), | |
Left.of([2, null]) | |
] | |
]) | |
[ | |
Right.of([1, 2]), | |
[ | |
[ | |
Right.of([2, null]), | |
[ | |
Left.of([5, null]), | |
Left.of([5, null]) | |
] | |
], | |
Left.of([2, null]) | |
] | |
] | |
Graph : (Cell, Cell) -> Either ( Either (a, b), Either (c, d) ) | |
mATH() | |
Graph : (Cell, Graph) | |
[a, b] => | |
Right.of([ | |
Right.of([1, 2]), | |
Right.of([ | |
2 | |
Right.of(3, 4)] | |
]) | |
]) | |
=> [ | |
1 | |
Right.of([2, 3]) | |
] | |
graph (2) = [ | |
Left.of([1, 2]), | |
[ | |
[ | |
Left.of([2, null]), | |
[ | |
Left.of([5, null]), | |
Left.of([5, null]) | |
] | |
], | |
Left.of([2, null]) | |
]) | |
] | |
graph (3) = [ | |
Left.of([1, 2]), | |
[ | |
[ | |
Left.of([2, null]), | |
[ | |
Left.of([5, null]), | |
Left.of([5, null]) | |
] | |
], | |
Left.of([2, null]) | |
] | |
] | |
Author
xaviervia
commented
Feb 26, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment