Hacker News new | past | comments | ask | show | jobs | submit login

How do you distinguish a tuple with both positional and named fields from a tuple that has a record as a field

Like how do you write the type of (1, {sum:2}) ? Is it different from (1 , sum :2)?






The syntax is a little funny for mostly historical reasons. The curly braces are only part of the record type syntax. There's no ambiguity there because curly braces aren't used for anything else in type annotations (well, except for named parameters inside a function type's parameter list, but that's a different part of the grammar).

so my examples would be (1, (sum:2)) and (1, sum:2)?

Yes, exactly.



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: