Stream: beginners

Topic: roc repl auto indentation


view this post on Zulip Seth Workman (Mar 07 2023 at 04:21):

I started going through some of the tutorial using "roc repl" and I'm curious if the repl is planning on having automatic indentation when creating functions. Example below

» test = \a -> (press enter after the ->)
… a (press enter - doesn't auto indent) -- compiler sad (error)

» test = \a -> (press enter after the ->)
… a (press space, press enter) -- compiler happy

view this post on Zulip Ayaz Hafiz (Mar 07 2023 at 04:55):

That is a great question and I think it would be a great idea to support. My suspicion is that it wouldn't even be too hard to implement with the current design of the roc parser+repl.

view this post on Zulip Seth Workman (Mar 07 2023 at 21:23):

I created an issue for this here https://github.com/roc-lang/roc/issues/5101

view this post on Zulip Luke Boswell (Mar 08 2023 at 09:08):

For anyone interested I think the relevant JS is in www/build/repl/repl.js

view this post on Zulip Brendan Hansknecht (Mar 08 2023 at 15:29):

That is probably just the web repl. Should be different rust code for the cli repl as well

view this post on Zulip Brian Carroll (Mar 09 2023 at 17:35):

The repl.js file prints out each string from Rust exactly as it is, preformatted, into a HTML pre tag. All of the formatting and indentation code is in Rust.

view this post on Zulip Brian Carroll (Mar 09 2023 at 17:36):

This is to share as much as possible and keep things consistent

view this post on Zulip Seth Workman (Mar 15 2023 at 14:35):

I was looking into the possibility of auto indent but it seems RustyLine doesn't support it. https://github.com/kkawakam/rustyline/issues/453
https://github.com/kkawakam/rustyline/pull/466

view this post on Zulip Seth Workman (Mar 15 2023 at 17:40):

Any ideas?


Last updated: Jul 06 2025 at 12:14 UTC