Stream: announcements

Topic: Snake case support PSA


view this post on Zulip Anthony Bullard (Dec 16 2024 at 20:21):

You may not have heard, but if you are using latest, and you eager to move your projects to using snake_case identifiers - you can run

roc format --migrate

And the Roc formatter will make that change for you! Use it today and give feedback

I feel like it’s important to note that this DOES NOT know if something is a built in or a platform/package provided member - so if you are not creating a dependency free (or lite) package using a version of the compiler with snake_cased builtins (which doesn’t exist yet) - use this with caution. Luckily the ROC compiler has your back with the resulting errors

view this post on Zulip jan kili (Dec 16 2024 at 20:28):

Thank you! Do you want feedback here?

view this post on Zulip Anthony Bullard (Dec 16 2024 at 20:32):

Sure!

view this post on Zulip Anthony Bullard (Dec 16 2024 at 20:33):

I can always move to bugs if needed

view this post on Zulip jan kili (Dec 16 2024 at 20:34):

Screenshot_20241216_133249.png
I ran it on basic-cli@main, and it seems to ignore module [ ... ] and exposes [ ... ] references.

view this post on Zulip Anthony Bullard (Dec 16 2024 at 20:39):

That’s Definitely a bug

view this post on Zulip Anthony Bullard (Dec 16 2024 at 20:40):

Easy fix. I’ll do that after work

view this post on Zulip Jasper Woudenberg (Dec 16 2024 at 20:51):

I've just ran it across my Roc platform code. I ran into the same cases that Jan did, but it also missed some other :camel: where I don't immediately see the pattern. There's examples of function definitions, function calls, string interpolations, and a couple more.

This is the roc code I ran the migration on. Easiest way to spot the problems after is to run roc check platform/main.roc. Note the commit, because I'm doing some manual fixes. Nice that the migration already did a lot of the work!
https://github.com/jwoudenberg/jay/tree/14e8bbeb62cbbbbdedc46e7a9e7b13d50ff02aa0/platform

view this post on Zulip Anthony Bullard (Dec 16 2024 at 20:54):

I will inspect and figure out the ast nodes I missed

view this post on Zulip Sam Mohr (Dec 16 2024 at 21:09):

I just ran this on Weaver and also saw a good number of nodes that weren't updated. Let me know if you want me to enumerate/make a GH issue or something

view this post on Zulip Anthony Bullard (Dec 16 2024 at 21:12):

Sam Mohr said:

I just ran this on Weaver and also saw a good number of nodes that weren't updated. Let me know if you want me to enumerate/make a GH issue or something

Can you post the bad output to a branch and share a link?

view this post on Zulip Sam Mohr (Dec 16 2024 at 21:18):

https://github.com/smores56/weaver/tree/incomplete-snake-case-conversion

view this post on Zulip Anthony Bullard (Dec 16 2024 at 22:03):

Thanks Sam!

view this post on Zulip Anthony Bullard (Dec 17 2024 at 00:39):

This branch should fix 99% of the above.

https://github.com/gamebox/roc/tree/fix-snake-case-formatting

The only thing is does NOT try to differentiate between builtins and application members.

view this post on Zulip Anthony Bullard (Dec 17 2024 at 00:39):

So this code will not be mergable _as is_ until the builtins and platform is updated as well

view this post on Zulip Sam Mohr (Dec 21 2024 at 06:41):

Looks like type args don't get consistently snake_cased:

module [truncate, CustomList]

CustomList my_item := List myItem

truncate : List myItem -> List *
truncate = \_my_items -> []

view this post on Zulip Sam Mohr (Dec 21 2024 at 06:42):

Pretty much everything else in Weaver got handled, though!

view this post on Zulip Anthony Bullard (Dec 21 2024 at 11:39):

I’ll get to that. Feel free to create an issue and assign it to me

view this post on Zulip Anthony Bullard (Dec 21 2024 at 15:13):

I created the issue @Sam Mohr ;-)

view this post on Zulip Anthony Bullard (Dec 21 2024 at 22:54):

This issue has ended up being weirder than I expected. The same exact string _seems_ to be going into the same function, but sometimes it doesn't come out formatted?

This has required me to add snapshot tests for the formatted (with migrate on) snapshots

view this post on Zulip Anthony Bullard (Dec 21 2024 at 22:58):

I wrote a unit test for it and of course it passes

view this post on Zulip Anthony Bullard (Dec 21 2024 at 23:02):

What in the actual hell...

view this post on Zulip Anthony Bullard (Dec 21 2024 at 23:02):

I'll have to look again tonight or tomorrow.

view this post on Zulip Anthony Bullard (Dec 21 2024 at 23:16):

This is all in compiler code

view this post on Zulip Luke Boswell (Dec 21 2024 at 23:18):

kk, nvm I was looking at the CI failures on your other PR

view this post on Zulip Anthony Bullard (Dec 22 2024 at 01:00):

Oh, did I hit a flake?


Last updated: Jul 26 2025 at 12:14 UTC