Stream: beginners

Topic: Online REPL


view this post on Zulip Arbil (Oct 05 2022 at 12:02):

Hey, I want to get a feeling of roc (and roll), but the online repl (https://www.roc-lang.org/repl/) doesn't work for me. Is this a known issue?

view this post on Zulip Brian Carroll (Oct 05 2022 at 12:16):

Can you tell us anything more specific? What browser are you on? what is not working?

view this post on Zulip Brian Carroll (Oct 05 2022 at 12:17):

Never mind, I see the issue.

view this post on Zulip Brian Carroll (Oct 05 2022 at 12:19):

It's a JS error on a DOM node, so it's weird it hasn't come up before. Internal compiler changes can't affect that.

view this post on Zulip Brian Carroll (Oct 05 2022 at 12:19):

OK, we'll have to look into this. Thanks for reporting it!

view this post on Zulip Arbil (Oct 05 2022 at 12:25):

Yeah, I tried a couple browsers, so figured it was something global. Happy you'll look into this!

view this post on Zulip Brian Carroll (Oct 05 2022 at 12:28):

Found the bug. In repl.js at line 215 I used .childNodes where it should be .children. I was able to edit that locally in Chrome devtools and it worked. You could try the same for now.

view this post on Zulip Arbil (Oct 05 2022 at 12:29):

Worked like a charm. Thanks!

view this post on Zulip Brian Carroll (Oct 05 2022 at 12:31):

Cool, I don't have time to do a PR for it right now but I'll get to it soon. Or if anyone wants to contribute the fix, add me as a reviewer!

view this post on Zulip Arbil (Oct 07 2022 at 03:54):

Is there a way to define abilities in the online repl? Doing

Inc has
    inc: a -> a
1

results in Abilities can only be defined on the top-level of a Roc module.

view this post on Zulip Luke Boswell (Oct 07 2022 at 04:08):

Is the REPL working for you? I just tried it and am getting a strange error. I logged an issue, and am trying to investigate further.

view this post on Zulip Arbil (Oct 07 2022 at 04:14):

Yes, here's a quickfix by Brian Carroll:

Found the bug. In repl.js at line 215 I used `.childNodes` where it should be `.children`. I was able to edit that locally in Chrome devtools and it worked. You could try the same for now.

view this post on Zulip Luke Boswell (Oct 07 2022 at 04:17):

It looks to be on the Roc side. When I check the source line 215 of repl.js looks correct, so I think this might be another issue. Issue #4232 Screen-Shot-2022-10-07-at-15.03.41.png

view this post on Zulip Brian Carroll (Oct 07 2022 at 04:33):

That's unrelated to what I fixed.

Looks like it's getting an empty line of Roc code and the parser (correctly) rejects that.

Also the parser doesn't format its errors properly, it assumes it's always running on the command line. That issue has been there for a while.

view this post on Zulip Brian Carroll (Oct 07 2022 at 06:59):

OK so the REPL works totally fine if you give it some actual code. The only thing that's broken here is that it should handle empty lines more gracefully. Thanks for creating the GH issue, I'll update the title to be more specific.

view this post on Zulip Arbil (Oct 07 2022 at 07:09):

Is it possible to get around This ability definition is not on the top-level of a module for ability definitions?

view this post on Zulip Arbil (Oct 07 2022 at 07:11):

Inc has inc: a -> a 1

view this post on Zulip Brian Carroll (Oct 07 2022 at 07:45):

Here's a fix for the online REPL newline issue https://github.com/roc-lang/roc/pull/4235

view this post on Zulip Brendan Hansknecht (Oct 07 2022 at 13:45):

@Ayaz Hafiz any thoughts on abilities in the repl?

view this post on Zulip Ayaz Hafiz (Oct 07 2022 at 14:05):

Regarding the abilities issue - no, that cannot be worked around today. The repl runs your code basically in the following way; suppose you enter <code>, we build a module

app "repl" provides [main] to "./internal_platform"

main =
  <code>

so it's actually always implicitly nested. We'll need to either change that, or allow abilities to be used in nested scopes - the former is easier to do (the latter has serious implications), but it will be a small project.


Last updated: Jul 06 2025 at 12:14 UTC