Skip to content
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

compile to JavaScript (SES) to run in browsers (and node.js?) #52

Open
3 tasks
dckc opened this issue Jul 31, 2015 · 6 comments
Open
3 tasks

compile to JavaScript (SES) to run in browsers (and node.js?) #52

dckc opened this issue Jul 31, 2015 · 6 comments

Comments

@dckc
Copy link
Member

dckc commented Jul 31, 2015

While typhon is cool, web browser deployment is important, if not essential, for many of the ways I want to use monte.

design sketch: source-to-source translation using one of the JS AST APIs.

It seems straightforward except for:

  • immutability - use freeze() and let as appropriate. and perhaps traits (IOU link)
  • ejectors - in a small runtime library, implement them using try/catch much like the python implementation
  • references - javascript evaluation of variables matches the first 3 steps of evaluation in E. For the fourth step, all bindings should go to promises and all evaluation should use .value or something.

This depends on SES, of course.

Here's hoping for time to give it a go...

@dckc
Copy link
Member Author

dckc commented Aug 1, 2015

darn; I don't think my references idea will work. noun phrases aren't the only place they show up. They're also in lists and such.

edit: I have since learned that references are actually just normal objects that proxy messages.

@dckc
Copy link
Member Author

dckc commented Aug 8, 2015

more ideas:

  • ADT for AST using flow
  • prototype source-to-source translation with sweetjs macros?
  • use traits to build objects, from miranda etc.
  • get ConstList from immutable

@dckc
Copy link
Member Author

dckc commented Aug 8, 2015

progress deserializing .ty to a flow-happy ADT: js-monte

Modern .js is really quite nice:

  • static typechecking with flow, with real-time feedback in emacs via flycheck

I got as far as deserializing typhon's AST for def [x, var y, [=>choc, =>van], bind z] := bzzt.

The ADT I built in rust matched the serialized form but not the actual kernel monte grammar. This js ADT matches kernel monte more closely. The deserialization code makes up the difference, sorta like the fromAST() methods in nodes.py

hmm... export var... not good. unfortunately, flow doesn't yet grok let

one happy byproduct: a JSON serialization of kernel monte

I doubt immutable.js will be worth the trouble for ConstList. Object.freeze() is probably most of the bang for much less buck.

for reference: 8f30ff72c9534ef77a82d182a32cabe40503b0f0 (hg: ebc2c69c69ff)

@dckc
Copy link
Member Author

dckc commented Aug 9, 2015

some conversion to javascript via escodegen is working; e.g. { x:= 42; traceln(x) } becomes x = __monte_runtime.wrapInt(42), traceln.run(x). I haven't added var yet because that's at the statement level and I'm only converting expressions so far.

Hmm... I suppose there should be a runtime.makeSlot(...) in there somewhere too.

dckc/js-monte@1700595

@dckc
Copy link
Member Author

dckc commented May 1, 2016

perhaps port Masque to purescript?

@dckc
Copy link
Member Author

dckc commented Oct 10, 2019

The https://github.com/monte-language/spotter work looks like a possible path here. js_of_ocaml and reason and all that are pretty mature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant