roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.19k stars 299 forks source link

Tutorial has spaces before colons in records where they shouldn't be. #4967

Closed human154 closed 1 year ago

human154 commented 1 year ago

The tutorial (as it appears at https://www.roc-lang.org/tutorial ) shows spaces before colons in multiple places, including in the following:

returnFoo { foo : "hi!", bar : "blah" }

also:

{ x, y } = { x : 5, y : 10 }

also:

original = { birds: 5, zebras : 2, iguanas : 7, goats : 1 }
fromScratch = { birds : 4, zebras : 2, iguanas : 3, goats : 1 }
fromOriginal = { original & birds : 4, iguanas : 3 }

... and multiple code snippets after that. (Perhaps this is an auto-formatting glitch?).

human154 commented 1 year ago

@rtfeldman is this related to the work on https://github.com/roc-lang/roc/pull/4947 ?

lukewilliamboswell commented 1 year ago

This may have been me when I converted to markdown. I liked the spaces to be honest. But I can see that it isn't consistent and note that the formatter currently removes the spaces. So I have updated the tutorial (I hope I got all of them) at #5008.

human154 commented 1 year ago

My understanding of the "proper" syntax here is based on what Richard Feldman wrote on Zulip:

"in Roc today:

always, what comes before = is a pattern always, an identifier followed by a : is a record field declaration always, an identifier followed by a blank space and then a : is a type declaration "

(the last two lines of that quote being relevant here.)

rtfeldman commented 1 year ago

Yeah, it's correct that these should be changed, as this is the way roc format will format them - happy to accept a PR for them!

rtfeldman commented 1 year ago

Oh, I see Luke's PR already did it - nice! 😄

human154 commented 1 year ago

Yes and now I also have a pull request for more: #5042