gleam-lang / playground

17 stars 3 forks source link

Show compiled Erlang #2

Open isaacharrisholt opened 3 months ago

isaacharrisholt commented 3 months ago

The code for this is mostly there on the JS side (in index.js and worker.js). We just need to add the compiled Erlang stdlib to the bundle like we do with the JS stdlib in order to get compilation working.

lpil commented 3 months ago

We just need to add the compiled Erlang stdlib to the bundle like we do with the JS stdlib in order to get compilation working.

It's not possible to execute Erlang in a browser so this isn't needed!

isaacharrisholt commented 3 months ago

Agreed we should execute the JS target, but it would be nice to show the compiled Erlang output, no?

lpil commented 3 months ago

Yes but you don't need to add compiled Erlang stdlib to the bundle to do that. The only thing you need to do is ask the compiler for Erlang rather than JavaScript and it'll just work.

isaacharrisholt commented 3 months ago

I tried doing that but it complained about missing libraries

isaacharrisholt commented 3 months ago

Here's the specific error:

error: Function without an implementation
   ┌─ /src/gleam/float.gleam:72:1
   │
72 │ fn do_round(a: Float) -> Int
   │ ^^^^^^^^^^^^^^^^^^^^^

We can't compile this function as it doesn't have an
implementation. Add a body or an external implementation
using the `@external` attribute.
lpil commented 3 months ago

That's due to your code removing the Erlang externals here: https://github.com/gleam-lang/playground/pull/1/files#diff-0065b9cdf8ba089285f3fbb25a377340d06c0259d93e36ef05c7c908ea950b71R195-R197

isaacharrisholt commented 3 months ago

Welp. Sounds about right. That'll teach me for copy-pasting stuff and then not reading it in detail 😅

Thanks! I'll add this to #1.