Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix #215] handle automatic projections from let pattern of tuples #216

Closed
wants to merge 1 commit into from

Conversation

flupe
Copy link
Contributor

@flupe flupe commented Nov 7, 2023

The issue was coming from Agda inlining let bindings. This translation leaked our encoding for tuples.

The example from #215 now gets compiled properly, but:

  • n-uples with n > 2 pattern-matched inside lets would still get compiled incorrectly because there is in fact no proper way to inline the let using projections (unless we also generate projections on the fly, like \(_, _, x) -> x).

    So let (x, y, z) = e in z would still compile to the incorrect snd (snd e). We probably need a reliable way to prevent such use of pattern-matching on let for n-uples, doesn't have to be now.

    We could compute the length of projection chains of Pair.fst and Pair.snd in the terms we get, the only issue being that the resulting error would not point to the location of the let, only the location of the problematic variable.

  • The projection fst and snd of Pair probably shouldn't get exported from Haskell.Prim.Tuple so as to enforce that the only way they pop up in terms is through inlining of let bindings.

Feedback welcome.

@jespercockx
Copy link
Member

n-uples with n > 2 pattern-matched inside lets would still get compiled incorrectly because there is in fact no proper way to inline the let using projections (unless we also generate projections on the fly, like (_, _, x) -> x).

As we discussed, maybe we should just bite the bullet and define n-tuples for n =< 10 by hand.

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