-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #529 from HigherOrderCO/465-add-mapper-statements
#465 Add mapper statements
- Loading branch information
Showing
12 changed files
with
235 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def main: | ||
x = 1 | ||
x @= lambda x: x + 1 | ||
map = { 0: 3, 1: 4 } | ||
map[1] += 1 | ||
map[1] @= lambda x: x * 2 | ||
return (x, map[1], map[0]) |
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,7 @@ | ||
def main: | ||
x = 1 | ||
x @= lambda x: x + 1 | ||
map = { 0: 3, 1: 4 } | ||
map[1] += 1 | ||
map[1] @= lambda x: x * 2 | ||
return (x, map[1], map[0]) |
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,85 @@ | ||
--- | ||
source: tests/golden_tests.rs | ||
input_file: tests/golden_tests/desugar_file/mapper_syntax.bend | ||
--- | ||
(Map/empty) = Map/Leaf | ||
|
||
(Map/get) = λa λb (a Map/get__C5 b) | ||
|
||
(Map/set) = λa λb λc (a Map/set__C10 c b) | ||
|
||
(Map/map) = λa λb λc (a Map/map__C5 b c) | ||
|
||
(main) = let (a, b) = main__C8; let (c, *) = (Map/get b 0); (main__C7, a, c) | ||
|
||
(Map/Node) = λa λb λc λd (d Map/Node/tag a b c) | ||
|
||
(Map/Leaf) = λa (a Map/Leaf/tag) | ||
|
||
(Map/Node/tag) = 0 | ||
|
||
(Map/Leaf/tag) = 1 | ||
|
||
(Map/get__C0) = λa λb λc λd let (e, f) = (Map/get c (/ a 2)); (e, (Map/Node b f d)) | ||
|
||
(Map/get__C1) = λ* λa λb λc λd let (e, f) = (Map/get d (/ a 2)); (e, (Map/Node b c f)) | ||
|
||
(Map/get__C2) = λa let {b c} = a; λd λe λf λ* (switch (% b 2) { 0: Map/get__C0; _: Map/get__C1; } c d e f) | ||
|
||
(Map/get__C3) = λ* λ* λa λ* λ* λb (a, b) | ||
|
||
(Map/get__C4) = λa let {b c} = a; λd let {e f} = d; λg let {h i} = g; λj let {k l} = j; (switch (== 0 k) { 0: Map/get__C2; _: Map/get__C3; } l b e h (Map/Node c f i)) | ||
|
||
(Map/get__C5) = λa switch a { 0: Map/get__C4; _: λ* λ* (*, Map/Leaf); } | ||
|
||
(Map/map__C0) = λa λb λc λd λe (Map/Node e (Map/map d (/ b 2) a) c) | ||
|
||
(Map/map__C1) = λ* λa λb λc λd λe (Map/Node e d (Map/map c (/ b 2) a)) | ||
|
||
(Map/map__C2) = λa λb let {c d} = b; λe λf λg (switch (% c 2) { 0: Map/map__C0; _: Map/map__C1; } a d e f g) | ||
|
||
(Map/map__C3) = λ* λa λ* λb λc λd (Map/Node (a d) c b) | ||
|
||
(Map/map__C4) = λa λb λc λd let {e f} = d; λg (switch (== 0 e) { 0: Map/map__C2; _: Map/map__C3; } g f c b a) | ||
|
||
(Map/map__C5) = λa switch a { 0: Map/map__C4; _: λ* λ* λ* Map/Leaf; } | ||
|
||
(Map/set__C0) = λa λb λc λd λe (Map/Node c (Map/set d (/ b 2) a) e) | ||
|
||
(Map/set__C1) = λ* λa λb λc λd λe (Map/Node c d (Map/set e (/ b 2) a)) | ||
|
||
(Map/set__C10) = λa switch a { 0: Map/set__C8; _: Map/set__C9; } | ||
|
||
(Map/set__C2) = λa λb let {c d} = b; λe λf λg (switch (% c 2) { 0: Map/set__C0; _: Map/set__C1; } a d e f g) | ||
|
||
(Map/set__C3) = λ* λa λ* λ* λb λc (Map/Node a b c) | ||
|
||
(Map/set__C4) = λa λb (Map/Node * (Map/set Map/Leaf (/ b 2) a) Map/Leaf) | ||
|
||
(Map/set__C5) = λ* λa λb (Map/Node * Map/Leaf (Map/set Map/Leaf (/ b 2) a)) | ||
|
||
(Map/set__C6) = λa λb let {c d} = b; (switch (% c 2) { 0: Map/set__C4; _: Map/set__C5; } a d) | ||
|
||
(Map/set__C7) = λ* λa λ* (Map/Node a Map/Leaf Map/Leaf) | ||
|
||
(Map/set__C8) = λa λb λc λd λe let {f g} = e; (switch (== 0 f) { 0: Map/set__C2; _: Map/set__C3; } d g a b c) | ||
|
||
(Map/set__C9) = λ* λa λb let {c d} = b; (switch (== 0 c) { 0: Map/set__C6; _: Map/set__C7; } a d) | ||
|
||
(main__C0) = (Map/set Map/empty 0 3) | ||
|
||
(main__C1) = λa (+ a 1) | ||
|
||
(main__C2) = (Map/set main__C0 1 4) | ||
|
||
(main__C3) = λa (* a 2) | ||
|
||
(main__C4) = (Map/map main__C2 1 main__C1) | ||
|
||
(main__C5) = (Map/map main__C4 1 main__C3) | ||
|
||
(main__C6) = λa (+ a 1) | ||
|
||
(main__C7) = (main__C6 1) | ||
|
||
(main__C8) = (Map/get main__C5 1) |
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,9 @@ | ||
--- | ||
source: tests/golden_tests.rs | ||
input_file: tests/golden_tests/run_file/mapper_syntax.bend | ||
--- | ||
NumScott: | ||
((λa (+ a 1) 1), (10, 3)) | ||
|
||
Scott: | ||
((λa (+ a 1) 1), (10, 3)) |