Skip to content

List Literal Patterns#1363

Open
martin-ilgner wants to merge 10 commits intomainfrom
feature/list-literal-patterns
Open

List Literal Patterns#1363
martin-ilgner wants to merge 10 commits intomainfrom
feature/list-literal-patterns

Conversation

@martin-ilgner
Copy link
Copy Markdown
Contributor

@martin-ilgner martin-ilgner commented Apr 10, 2026

Starting to implement #821

@martin-ilgner martin-ilgner moved this to Waiting for Review in Effekt Hackathon Spring 2026 Apr 10, 2026
@martin-ilgner martin-ilgner marked this pull request as ready for review April 10, 2026 11:42
Copy link
Copy Markdown
Contributor

@jiribenes jiribenes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't (yet?) do the .. part of the issue #821, so we can't match on tails :(

and I'd like to see a few more pos tests like if ([None(), Some(42) is [head, Some(x)]) { ... } and with val [x, y] = foo { ... } and foo { case [x, y, z, a] => ... } :)

@github-project-automation github-project-automation Bot moved this from Waiting for Review to In Progress in Effekt Hackathon Spring 2026 Apr 10, 2026
@martin-ilgner martin-ilgner moved this from In Progress to Waiting for Review in Effekt Hackathon Spring 2026 Apr 10, 2026
@jiribenes jiribenes moved this from Waiting for Review to In Progress in Effekt Hackathon Spring 2026 Apr 10, 2026
@martin-ilgner martin-ilgner self-assigned this Apr 10, 2026
@martin-ilgner
Copy link
Copy Markdown
Contributor Author

  • how do we make sure that there's only one "tail" pattern? where's the latest we can fail here

I made it so that after a tail pattern, ] is expected

  • do we add it as a token, or "just" eat two . tokens?

There is already a .. token

  • what's case [..rest] => ...? error or the whole list?

Whole list, why not

  • how do we write an ignored splat? can we just write [head, ..] or do we need [head, .._]?

Write [head, ..]

  • trailing commas?

Not after a splat. (Could change this, but I think there is no argument for it, as splat is always last)

@martin-ilgner
Copy link
Copy Markdown
Contributor Author

What do you mean with with val [x, y] = foo { ... }? Is it even possible/not a compile error because length of list is unknown? Maybe I could do val [x, ..y] = lst

@martin-ilgner
Copy link
Copy Markdown
Contributor Author

@jiribenes

@jiribenes
Copy link
Copy Markdown
Contributor

What do you mean with with val [x, y] = foo { ... }? Is it even possible/not a compile error because length of list is unknown?

Ah, sorry, you can do val-else (val [x, y] = foo { ... } else panic("ohno")) and with-val-else :)

with val obj
and obj is Dict(fields)
and fields.lookup("user") is Some(userObj)
and userObj is Dict(userFields)
and userFields.lookup("name") is Some(String(name))
and userFields.lookup("age") is Some(Number(age))
= data() else None()

@martin-ilgner
Copy link
Copy Markdown
Contributor Author

martin-ilgner commented Apr 15, 2026

I also rewrote manyTrailing. Should be enough pos tests for now 🙏

@martin-ilgner martin-ilgner requested a review from jiribenes April 17, 2026 06:09
@martin-ilgner martin-ilgner moved this from In Progress to Waiting for Review in Effekt Hackathon Spring 2026 Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting for Review

Development

Successfully merging this pull request may close these issues.

2 participants