Stream: beginners

Topic: roc-format stdin


view this post on Zulip Georges Boris (May 27 2023 at 20:04):

folks, any way to run roc format passing in a string directly? this can be used by code editors for auto-format for instance. :)

view this post on Zulip Richard Feldman (May 27 2023 at 20:07):

I actually want to have a libroc or something - like a C library - for use cases like this

view this post on Zulip Richard Feldman (May 27 2023 at 20:08):

so it can be lower overhead than having to spawn the CLI, and also means the main Roc CLI can avoid having to mix tooling use cases in with normal Roc program author use cases :big_smile:

view this post on Zulip Ajai Nelson (May 27 2023 at 21:00):

If you want something very hacky, a couple days ago, I quickly modified https://github.com/roc-lang/roc/blob/main/crates/cli/src/format.rs to make a Rust function that formats a string: https://gist.github.com/AjaiKN/a0778bf34d525686748a6568b7c298ba. I used cargo add --git https://github.com/roc-lang/roc roc_fmt and cargo add --git https://github.com/roc-lang/roc roc_parse to get the dependencies from the main branch on GitHub.


Last updated: Jul 06 2025 at 12:14 UTC