From d97e121e38863fa8818322bfff6d102d3c1650e3 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 10 Oct 2022 19:25:57 +0200 Subject: [PATCH] some more tweeks --- editor/public/saved.json | 22 ++++++++++++++++++++-- editor/src/other.js | 9 ++++++--- eyg/src/eyg/entry.gleam | 20 +++++++++++++++----- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/editor/public/saved.json b/editor/public/saved.json index ffa20a566..6f5a56563 100644 --- a/editor/public/saved.json +++ b/editor/public/saved.json @@ -3057,8 +3057,26 @@ "elements": [] }, "then": { - "node": "Binary", - "value": "TODO encode" + "node": "Call", + "function": { + "node": "Access", + "value": { + "node": "Variable", + "label": "builtin" + }, + "key": "serialize" + }, + "with": { + "node": "Function", + "pattern": { + "node": "Variable", + "label": "" + }, + "body": { + "node": "Tuple", + "elements": [] + } + } } } ] diff --git a/editor/src/other.js b/editor/src/other.js index af24cd3a3..382cbe7e0 100644 --- a/editor/src/other.js +++ b/editor/src/other.js @@ -7,13 +7,16 @@ import data from "../public/saved.json"; // let target = new URL(document.currentScript.src).hash.slice(1); // console.log(target, Analysis); -(async function name() { +async function GoGoGo() { const source = Encode.from_json(data); const initial = Entry.interpret_client(source, "counter"); console.log(initial); const { default: next } = await import("../public/saved.json"); - console.log(Encode.from_json(data)); -})(); + console.log(Encode.from_json(next)); +} +console.log(window, GoGoGo); +window.GoGoGo = GoGoGo; +GoGoGo(); // Started doing this because the code gen was troublesome, also in code gen we will nee to pull in the loader // here we have can use the already existing gleam .run diff --git a/eyg/src/eyg/entry.gleam b/eyg/src/eyg/entry.gleam index 4c2d75d70..eeb268a9a 100644 --- a/eyg/src/eyg/entry.gleam +++ b/eyg/src/eyg/entry.gleam @@ -1,4 +1,6 @@ import gleam/io +import gleam/map +import gleam/option.{None} import gleam/string import eyg/ast/encode import eyg/ast/expression as e @@ -7,20 +9,26 @@ import eyg/interpreter/effectful import eyg/interpreter/tail_call import gleam/javascript/array import eyg/interpreter/interpreter as r +import eyg/ast/pattern as p import eyg/analysis 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 b(args) { - Ok(r.Binary("done")) + Ok(args) } +fn tree() { + r.Function(p.Variable("x"), e.tuple_([e.variable("x"),e.variable("x")]), map.new(), None) + } + // uses default builtin that need moving out of effectful // has an entry point key should eventually be a hash // maybe rename interpret standard @@ -35,11 +43,13 @@ pub fn interpret_client(source, key, display, on_click) { io.debug("---- typed") let #(xtyped, typer) = typer.expand_providers(typed, typer, []) - // assert Ok(term) = effectful.eval(editor.untype(xtyped)) - // io.debug(term) + // Running the interpreter kills the client + // assert Ok(term) = effectful.eval(editor.untype(xtyped)) + // io.debug(term) + |> io.debug + io.debug("expanded") + effectful.eval_call(tree(), r.Binary("nothing exciting"), effectful.real_log) |> io.debug - // effectful.eval_call(r.BuiltinFn(b), term, effectful.real_log) - // |> io.debug // // TODO make an AST the requires rendering // term }