Skip to content

Feature request: switch from infer to check when given "concrete" infer pattern #96

Open

Description

@wilbowma

Not actually sure this is possible, but it ought to be, intuitively.

For context, I'm starring at this line
https://github.com/wilbowma/cur/blob/turnstile-merging/cur-lib/cur/curnel/turnstile-impl/dep-ind-cur2%2Bdata2.rkt#L346

This line annoys me because it branches on the number of parameters and indices, but actually has nothing to do with the number of parameters and indices. Instead, it is giving better inference and error messages by switching to check mode instead of inference mode when possible. This is possible to do this when we would be generating a pattern that is actually a concrete type, and it happens to be the case that we would generate a concrete type when there are 0 parameters and indices.

It seems like Turnstile ought to be able to detect when a infer pattern is actually concrete syntax instead of a pattern, and automatically switch from infer to check in that case. If so, it would be a great feature, as it would automagically improve a user's type system.

This situation probably doesn't come up so much in source Turnstile, but comes up any time we use this pattern variable instantiation technique, i.e., when generating Turnstile.

Activity

  1. stchang commented on Aug 9, 2019

    @stchang
    Owner

    Pasting the actual lines of code here, since the code is constantly changing

            #,(if (zero? (+ num-params num-idxs))
                  ; NB: Again, must handle id transformers differently.
                  ; Luckily, we can also be in checking mode in that case.
                  #'[⊢ v ≫ v- ⇐ TY]
                  #'[⊢ v ≫ v- ⇒ (TY-patexpand A ... i* ...)])
    

    So you would like to only write the second case, and when A and i* are empty, it automatically switches to checking because (TY-patexpand) is not actually matching any new pattern variables?

  2. wilbowma commented on Aug 9, 2019

    @wilbowma
    ContributorAuthor

    Right.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions