diff --git a/eyg/src/eyg/ast/encode.gleam b/eyg/src/eyg/ast/encode.gleam index 9dfa2dfb3..98eb02df3 100644 --- a/eyg/src/eyg/ast/encode.gleam +++ b/eyg/src/eyg/ast/encode.gleam @@ -207,7 +207,6 @@ pub fn from_json(json: JSON) { ast.variable(assert_string(label)) } "Let" -> { - let [#("pattern", pattern), #("value", value), #("then", then)] = rest let pattern = pattern_from_json(pattern) let value = from_json(value) diff --git a/eyg/src/eyg/codegen/javascript.gleam b/eyg/src/eyg/codegen/javascript.gleam index 7c783cf50..85fad8299 100644 --- a/eyg/src/eyg/codegen/javascript.gleam +++ b/eyg/src/eyg/codegen/javascript.gleam @@ -173,8 +173,7 @@ pub fn escape_string(raw) { |> string.replace("\\", "\\\\") |> string.replace("'", "\\'") |> string.replace("\"", "\\\"") - -// Not js but browser + // Not js but browser |> string.replace("<", "\\<") |> string.replace(">", "\\>") } diff --git a/eyg/src/eyg/entry.gleam b/eyg/src/eyg/entry.gleam index 1a3532bf5..4c2d75d70 100644 --- a/eyg/src/eyg/entry.gleam +++ b/eyg/src/eyg/entry.gleam @@ -12,17 +12,15 @@ import eyg/typer import eyg/typer/monotype as t import eyg/editor/editor -fn update(page, interrupt, display, on_click) { - - io.debug(page) - display(page) +fn update(page, interrupt, display, on_click) { + io.debug(page) + display(page) +} - } +fn b(args) { + Ok(r.Binary("done")) +} - -fn b(args) { - Ok(r.Binary("done")) - } // uses default builtin that need moving out of effectful // has an entry point key should eventually be a hash // maybe rename interpret standard @@ -30,17 +28,18 @@ fn b(args) { // All the runtime stuff is in gleam terms // TODO are there any gleam helpers to turn tuples into things pub fn interpret_client(source, key, display, on_click) { - io.debug("hooo") - let init = e.access(e.access(source, key), "init") - io.debug(init) + io.debug("hooo") + let init = e.access(e.access(source, key), "init") + io.debug(init) let #(typed, typer) = analysis.infer(init, t.Unbound(-1), []) io.debug("---- typed") - let #(xtyped, typer) = typer.expand_providers(typed, typer, []) -// assert Ok(term) = effectful.eval(editor.untype(xtyped)) -// io.debug(term) - |> io.debug -// effectful.eval_call(r.BuiltinFn(b), term, effectful.real_log) -// |> io.debug -// // TODO make an AST the requires rendering -// term -} \ No newline at end of file + let #(xtyped, typer) = + typer.expand_providers(typed, typer, []) + // assert Ok(term) = effectful.eval(editor.untype(xtyped)) + // io.debug(term) + |> io.debug + // effectful.eval_call(r.BuiltinFn(b), term, effectful.real_log) + // |> io.debug + // // TODO make an AST the requires rendering + // term +} diff --git a/eyg/src/eyg/interpreter/effectful.gleam b/eyg/src/eyg/interpreter/effectful.gleam index 9d70e5a65..f91854a65 100644 --- a/eyg/src/eyg/interpreter/effectful.gleam +++ b/eyg/src/eyg/interpreter/effectful.gleam @@ -84,27 +84,26 @@ fn term_serialize(term) { // TODO does with work can we have outside poller on_code: (f) => { document.oncode = f } });", -// This didn't work because of rendering captured variables for a fn within some scope. -// We need a whole review of rendering or use interpreter -// "(({init}) => { -// console.log(init, 'initial state') -// const update = ({page, interrupt}) => { -// document.body.innerHTML = page -// document.onclick = () => update(interrupt({Click: 'key'})) -// document.oncode = (code) => update(interrupt({Code: code})) -// TODO this needs the codegen part of loader -// } -// update(init) -// // TODO set interval -// })" ) + // This didn't work because of rendering captured variables for a fn within some scope. + // We need a whole review of rendering or use interpreter + // "(({init}) => { + // console.log(init, 'initial state') + // const update = ({page, interrupt}) => { + // document.body.innerHTML = page + // document.onclick = () => update(interrupt({Click: 'key'})) + // document.oncode = (code) => update(interrupt({Code: code})) + // TODO this needs the codegen part of loader + // } + // update(init) + // // TODO set interval + // })" let page = string.concat([""]) // assert r.Function() = term Ok(r.Binary(page)) } - fn env() { map.new() |> map.insert("do", r.BuiltinFn(do)) diff --git a/eyg/src/eyg/interpreter/interpreter.gleam b/eyg/src/eyg/interpreter/interpreter.gleam index 28dadb2ef..a10abcf18 100644 --- a/eyg/src/eyg/interpreter/interpreter.gleam +++ b/eyg/src/eyg/interpreter/interpreter.gleam @@ -12,7 +12,6 @@ import eyg/analysis import eyg/typer import eyg/typer/monotype as t - pub type Object { Binary(String) Pid(Int) @@ -119,12 +118,14 @@ pub fn render_object(object) { // Builtins should never be included, I need to check variables used in a previous step // Function(_,_,_,_) -> todo("this needs compile again but I need a way to do this without another type check") Function(pattern, body, captured, _) -> { - // TODO this needs to render captured to be useful - let #(typed, typer) = analysis.infer(e.function(pattern, body), t.Unbound(-1), []) - let #(typed, typer) = typer.expand_providers(typed, typer, []) - javascript.render_to_string(typed, typer) + // TODO this needs to render captured to be useful + let #(typed, typer) = + analysis.infer(e.function(pattern, body), t.Unbound(-1), []) + let #(typed, typer) = typer.expand_providers(typed, typer, []) + javascript.render_to_string(typed, typer) } - BuiltinFn(_) -> "null /* we aren't using builtin here should be part of env */" + BuiltinFn(_) -> + "null /* we aren't using builtin here should be part of env */" // TODO remove Coroutine/ready there where and old experiment Coroutine(_) -> "null" Ready(_, _) -> "null" diff --git a/eyg/src/eyg/typer/monotype.gleam b/eyg/src/eyg/typer/monotype.gleam index 53c8d7c17..0e1ae6aeb 100644 --- a/eyg/src/eyg/typer/monotype.gleam +++ b/eyg/src/eyg/typer/monotype.gleam @@ -76,8 +76,15 @@ pub fn literal(monotype) { // need to add effects string.concat(["new T.Function(", literal(from), ",", literal(to), ")"]) Unbound(i) -> string.concat(["new T.Unbound(", int.to_string(i), ")"]) - Recursive(i, rest) -> string.concat(["new T.Recursive(", int.to_string(i), ", ", literal(rest), ")"]) - Native(_, _) -> { + Recursive(i, rest) -> + string.concat([ + "new T.Recursive(", + int.to_string(i), + ", ", + literal(rest), + ")", + ]) + Native(_, _) -> { io.debug(monotype) todo("ss literal") } diff --git a/eyg/src/platform/browser.gleam b/eyg/src/platform/browser.gleam index a92e1d4ca..3a08250d0 100644 --- a/eyg/src/platform/browser.gleam +++ b/eyg/src/platform/browser.gleam @@ -36,13 +36,13 @@ fn builtins() { ) |> add_field("serialize", t.Function(t.Unbound(0), t.Binary, t.empty)) |> add_field( - "compile", - t.Function( - t.Tuple([t.Binary, t.Binary]), - t.Union([#("OK", t.Unbound(0)), #("Error", t.Binary)], Some(1)), - t.empty, - ), - ) + "compile", + t.Function( + t.Tuple([t.Binary, t.Binary]), + t.Union([#("OK", t.Unbound(0)), #("Error", t.Binary)], Some(1)), + t.empty, + ), + ) } fn add_field(state, key, type_) {