Skip to content

Conversation

@BruceEckel
Copy link
Contributor

Updated syntax for record type notation.

Updated syntax for record type notation.
@magnus-madsen magnus-madsen changed the title Fix record type syntax from '=' to ':' fix: record type syntax from '=' to ':' Jan 24, 2026
@magnus-madsen
Copy link
Member

Hello @BruceEckel :-) And thank you for your contribution. Changes auto-deploy every hour.

@magnus-madsen magnus-madsen merged commit 87d67e3 into flix:master Jan 24, 2026
1 check passed
@BruceEckel
Copy link
Contributor Author

I submitted that before I read the rest of https://doc.flix.dev/records.html, and started encountering that syntax everywhere. I assumed it was an error because everywhere else a colon is used to indicate a type, so this looked out of place. But then I tried taking another example further down in the doc:

def f(r: {x = Int32, y = Int32}): Int32 = r#x + r#y

And "fixing" it to what I assumed it should be:

def f(r: {x: Int32, y: Int32}): Int32 = r#x + r#y

And this did not work. So my submission was incorrect and it should be reverted.

Since this special-case style of type definition is counterintuitive, I'm guessing you had a reason for doing it, perhaps to make named parameters work?

@magnus-madsen
Copy link
Member

Ah yes, I was too fast. Indeed the syntax is:

def main(): Unit \ IO =
    let point: {x = Int32, y = Int32} = {x = 123, y = 456};
    println(point#x * point#y)

@magnus-madsen
Copy link
Member

The reason is that : is used for type ascription and kind ascription. Like so:

age: Int32

but also

String: Type
Int32: Type
IO: Eff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants