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?
Can you tell us anything more specific? What browser are you on? what is not working?
Never mind, I see the issue.
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.
OK, we'll have to look into this. Thanks for reporting it!
Yeah, I tried a couple browsers, so figured it was something global. Happy you'll look into this!
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.
Worked like a charm. Thanks!
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!
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.
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.
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.
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
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.
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.
Is it possible to get around This ability definition is not on the top-level of a module
for ability definitions?
Inc has
inc: a -> a
1
Here's a fix for the online REPL newline issue https://github.com/roc-lang/roc/pull/4235
@Ayaz Hafiz any thoughts on abilities in the repl?
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