Skip to content

Commit

Permalink
copy group fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bcpeinhardt committed Nov 29, 2024
1 parent 8bd9af7 commit 1c53334
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
44 changes: 37 additions & 7 deletions priv/static/squared_away.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,15 @@ function trim_left(string3) {
function trim_right(string3) {
return string3.replace(right_trim_regex, "");
}
function print_debug(string3) {
if (typeof process === "object" && process.stderr?.write) {
process.stderr.write(string3 + "\n");
} else if (typeof Deno === "object") {
Deno.stderr.writeSync(new TextEncoder().encode(string3 + "\n"));
} else {
console.log(string3);
}
}
function ceiling(float3) {
return Math.ceil(float3);
}
Expand Down Expand Up @@ -2724,6 +2733,14 @@ function guard(requirement, consequence, alternative) {
}
}

// build/dev/javascript/gleam_stdlib/gleam/io.mjs
function debug(term) {
let _pipe = term;
let _pipe$1 = inspect2(_pipe);
print_debug(_pipe$1);
return term;
}

// build/dev/javascript/lustre/lustre/effect.mjs
var Effect = class extends CustomType {
constructor(all) {
Expand Down Expand Up @@ -5096,6 +5113,16 @@ function visit_cross_labels(te, f) {
} else {
return new Error(void 0);
}
} else if (te instanceof Group2) {
let t2 = te.type_;
let inner = te.expr;
let $ = visit_cross_labels(inner, f);
if (!$.isOk()) {
return new Error(void 0);
} else {
let modified_expr = $[0];
return new Ok(new Group2(t2, modified_expr));
}
} else {
return new Ok(te);
}
Expand Down Expand Up @@ -5230,6 +5257,8 @@ function to_string11(te) {
return "=" + do_to_string2(te);
} else if (te instanceof BinaryOp2) {
return "=" + do_to_string2(te);
} else if (te instanceof Group2) {
return "=" + do_to_string2(te);
} else if (te instanceof BuiltinSum2) {
return "=" + do_to_string2(te);
} else if (te instanceof CrossLabel2) {
Expand Down Expand Up @@ -8524,7 +8553,7 @@ function update(model, msg) {
throw makeError(
"let_assert",
"squared_away",
264,
265,
"",
"Pattern match failed, no pattern matched the value.",
{ value: maybe_expr }
Expand All @@ -8539,7 +8568,7 @@ function update(model, msg) {
throw makeError(
"let_assert",
"squared_away",
272,
273,
"",
"Pattern match failed, no pattern matched the value.",
{ value: $ }
Expand All @@ -8566,7 +8595,7 @@ function update(model, msg) {
throw makeError(
"let_assert",
"squared_away",
292,
293,
"",
"Pattern match failed, no pattern matched the value.",
{ value: $1 }
Expand Down Expand Up @@ -8606,6 +8635,7 @@ function update(model, msg) {
} else if (msg instanceof UserShiftPressedArrowDown) {
let cell = msg.cell;
let maybe_cell_below = cell_underneath(model.src_grid, cell);
debug(get4(model.type_checked_grid, cell));
if (!maybe_cell_below.isOk() && !maybe_cell_below[0]) {
return [model, none()];
} else {
Expand All @@ -8625,7 +8655,7 @@ function update(model, msg) {
throw makeError(
"let_assert",
"squared_away",
332,
334,
"",
"Pattern match failed, no pattern matched the value.",
{ value: maybe_expr }
Expand All @@ -8640,7 +8670,7 @@ function update(model, msg) {
throw makeError(
"let_assert",
"squared_away",
337,
339,
"",
"Pattern match failed, no pattern matched the value.",
{ value: $ }
Expand All @@ -8667,7 +8697,7 @@ function update(model, msg) {
throw makeError(
"let_assert",
"squared_away",
356,
358,
"",
"Pattern match failed, no pattern matched the value.",
{ value: $1 }
Expand Down Expand Up @@ -9284,7 +9314,7 @@ function main() {
throw makeError(
"let_assert",
"squared_away",
35,
36,
"main",
"Pattern match failed, no pattern matched the value.",
{ value: $ }
Expand Down
1 change: 1 addition & 0 deletions src/squared_away.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import gleam/bool
import gleam/dict
import gleam/dynamic
import gleam/int
import gleam/io
import gleam/javascript/promise
import gleam/list
import gleam/option.{type Option, None, Some}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ pub fn visit_cross_labels(
_, _ -> Error(Nil)
}
}

Group(t, inner) -> {
case visit_cross_labels(inner, f) {
Error(_) -> Error(Nil)
Ok(modified_expr) -> Ok(Group(t, expr: modified_expr))
}
}
_ -> Ok(te)
}
}
Expand Down Expand Up @@ -92,6 +97,7 @@ pub fn to_string(te: TypedExpr) -> String {
Label(_, _, _)
| UnaryOp(_, _, _)
| BinaryOp(_, _, _, _)
| Group(_, _)
| BuiltinSum(_, _)
| CrossLabel(_, _, _, _) -> "=" <> do_to_string(te)
_ -> do_to_string(te)
Expand Down

0 comments on commit 1c53334

Please sign in to comment.