Skip to content

Spike of recursion #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eyg/bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function main() {
let failures = 0;

for await (let entry of await opendir(dir)) {
if (!entry.name.endsWith("test.js")) continue;
if (!entry.name.endsWith("terms_test.js")) continue;
let path = "../" + dir + entry.name;
process.stdout.write("\nlanguage/" + entry.name.slice(0, -3) + ":\n ");
let module = await import(path);
Expand Down
3 changes: 3 additions & 0 deletions eyg/src/eyg/ast/editor.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,9 @@ pub fn get_element(tree: e.Expression(a, b), position) -> Element(a, b) {
let [#(_, child), .._] = list.drop(fields, i)
get_element(child, rest)
}
// TODO need to get out the union tag
#(_, e.Tagged(_tag, value)), [1, ..rest] -> get_element(value, rest)

#(_, e.Let(pattern, _, _)), [0, ..rest] -> get_pattern(pattern, rest, tree)
#(_, e.Let(_, value, _)), [1, ..rest] -> get_element(value, rest)
#(_, e.Let(_, _, then)), [2, ..rest] -> get_element(then, rest)
Expand Down
20 changes: 16 additions & 4 deletions eyg/src/eyg/ast/expression.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ pub fn example(config, hole) {
}
}

fn tagged(name, value) {
function(p.Row([#(name, "then")]), call(variable("then"), value))
}

// fn tagged(name, value) {
// function(p.Row([#(name, "then")]), call(variable("then"), value))
// }
pub fn lift_type(_config, hole) {
case hole {
t.Function(from, _to) -> {
Expand Down Expand Up @@ -154,6 +153,7 @@ pub type Node(m, g) {
Binary(value: String)
Tuple(elements: List(Expression(m, g)))
Row(fields: List(#(String, Expression(m, g))))
Tagged(tag: String, value: Expression(m, g))
Variable(label: String)
Let(pattern: Pattern, value: Expression(m, g), then: Expression(m, g))
Function(pattern: Pattern, body: Expression(m, g))
Expand Down Expand Up @@ -192,3 +192,15 @@ pub fn tuple_(elements) {
pub fn variable(label) {
#(dynamic.from(Nil), Variable(label))
}

pub fn row(fields) {
#(dynamic.from(Nil), Row(fields))
}

pub fn tagged(tag, value) {
#(dynamic.from(Nil), Tagged(tag, value))
}

pub fn hole() {
#(dynamic.from(Nil), Hole)
}
Loading