zesterer / tao

A statically-typed functional language with generics, typeclasses, sum types, pattern-matching, first-class functions, currying, algebraic effects, associated types, good diagnostics, etc.
https://tao.jsbarretto.com/
Mozilla Public License 2.0
1.09k stars 23 forks source link

WebAssembly #57

Open flip111 opened 6 months ago

flip111 commented 6 months ago

Does the compiler run on WebAssembly (wasm)? Is such feature planned?

zesterer commented 6 months ago

When you say 'run on', what do you mean?

Currently, the only compiler backend is a simple bytecode interpreter. This is largely because I've been putting far more focus into the front (syntax, type system) and middle (optimiser) ends so far. In time, I want to support cranelift and perhaps even LLVM as backends.

If you're talking about the compiler itself: yes! When you visit tao.jsbarretto.com and run code, you're actually running a copy of the compiler that's been compiled to WASM and is running in your browser locally.

flip111 commented 6 months ago

If you're talking about the compiler itself: yes!

Yes that was my question. Though it would be very interesting if webassembly can also be a backend. How does it execute right now in the playground?

by the way playground seems to be broken when i hit run

[03] Error: Lang item not is missing
[03] Error: Lang item neg is missing
[03] Error: Lang item add is missing
[03] Error: Lang item sub is missing
[03] Error: Lang item mul is missing
[03] Error: Lang item div is missing
[03] Error: Lang item eq is missing
[03] Error: Lang item ord_ext is missing
[03] Error: Lang item and_ is missing
[03] Error: Lang item or_ is missing
[03] Error: Lang item join is missing
[03] Error: Lang item go is missing
[03] Error: Lang item bool is missing
zesterer commented 6 months ago

You need to import at minimum the core library (and also main if you want to run anything), since it contains lang items required for the language (like operator typeclasses). You can do that by adding the following to the top of the file.

mod main = "../lib/main.tao"