Stream: compiler development

Topic: roc fmt empty line between functions


view this post on Zulip Anton (Apr 21 2026 at 09:27):

Can I make roc fmt add an empty line between the last line of the function implementation and the next doc comment?
So, this:

        is_empty : Str -> Bool
        is_empty = |str| Str.count_utf8_bytes(str) == 0
        ## Concatenates two strings together.
        ## ```roc
        ## expect "ab".concat("cd") == "abcd"
        ## expect "hello".concat("") == "hello"
        ## expect "".concat("") == ""
        ## ```
        concat : Str, Str -> Str
        ## Determines whether or not the first Str contains the second.
        ## ```roc
        ## expect "foobarbaz".contains("bar")
        ## expect !"apple".contains("orange")
        ## expect "anything".contains("")
        ## ```
        contains : Str, Str -> Bool

Becomes:

        is_empty : Str -> Bool
        is_empty = |str| Str.count_utf8_bytes(str) == 0

        ## Concatenates two strings together.
        ## ```roc
        ## expect "ab".concat("cd") == "abcd"
        ## expect "hello".concat("") == "hello"
        ## expect "".concat("") == ""
        ## ```
        concat : Str, Str -> Str

        ## Determines whether or not the first Str contains the second.
        ## ```roc
        ## expect "foobarbaz".contains("bar")
        ## expect !"apple".contains("orange")
        ## expect "anything".contains("")
        ## ```
        contains : Str, Str -> Bool

view this post on Zulip Luke Boswell (Apr 21 2026 at 09:40):

I like that -- but only when there is a doc comment.

view this post on Zulip Anton (Apr 21 2026 at 13:08):

I created "good first issue" #9356 for this.

view this post on Zulip Ian McLerran (May 07 2026 at 16:55):

Just out of curiosity, why wouldn't we want a blank line between functions when there is NOT a doc comment? Do we really want:

is_empty : Str -> Bool
is_empty = |str| Str.count_utf8_bytes(str) == 0
concat : Str, Str -> Str
contains : Str, Str -> Bool

Instead of:

is_empty : Str -> Bool
is_empty = |str| Str.count_utf8_bytes(str) == 0

concat : Str, Str -> Str

contains : Str, Str -> Bool

view this post on Zulip Richard Feldman (May 09 2026 at 01:31):

yeah that sounds like a good change to me!

view this post on Zulip Anton (May 09 2026 at 08:44):

I'll implement that right now

view this post on Zulip Anton (May 09 2026 at 12:49):

Done in PR#9399


Last updated: May 23 2026 at 12:51 UTC