Skip to content

Allow pattern matching to constrain type members of function arguments #5828

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

Open
Blaisorblade opened this issue Jan 31, 2019 · 1 comment
Open

Comments

@Blaisorblade
Copy link
Contributor

Blaisorblade commented Jan 31, 2019

Simplifying from @b-studios #4376 (comment):

scala> object existentials {
     |
     |   sealed trait Exists { type R }
     |   type Rank2[F[_]] = (e: Exists) |=> F[e.R]
     |
     |   type ~>[F[_], G[_]] = Rank2[[X] => F[X] => G[X]]
     |
     |   val nat: List ~> Option = {
     |     case Nil => None
     |     // also: x isn't refined to e.R
     |     case x :: _ => Some(x)
     |   }
     | }
11 |    case x :: _ => Some(x)
   |                        ^
   |                        Found:    Any(x)
   |                        Required: evidence$1.R

Since @abgruszecki is working on GADT type refinement and using singletons, we might make progress. Since @milessabin recently said he's fixing bugs with higher-kinded types, tagging him too.

@abgruszecki abgruszecki changed the title GADT type refinement failure for singletons Allow pattern matching to constrain type members of function arguments Jan 31, 2019
@abgruszecki
Copy link
Contributor

Tentatively classifying under "enhancement". Might be doable if we make term symbols valid arguments for GADTMap. #5747 is quite likely relevant, since it allows constraining singleton types with null-checks.

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

No branches or pull requests

2 participants