Skip to content

Enable some recursive gadt to work with inline match #10390

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

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

bishabosha
Copy link
Member

@bishabosha bishabosha commented Nov 19, 2020

Enable one encoding of recursive gadts to work with inline match, e.g:

enum Nat:
  case Zero
  case Succ[N <: Nat.Refract](pred: N)

object Nat:
  type Refract = Zero.type | Succ[_]

If the recursive part is fixed to a subtype of the union of the
cases of the enum, enable inline match to reduce cases.

Notes: this encoding could be supported by a
compiletime.Refract[S] type to split cases of a sum type.

This does not help #6781 due to requiring a precise bound to narrow the predecessor of Succ, it would be good to invest some time in inline match to make it work for the case where Succ has a weaker upper bound

@bishabosha
Copy link
Member Author

bishabosha commented Nov 19, 2020

the problem being solved here is that inline proxies and inline match scrutinee symbols were previously stripped of term ref singletons, which means that both objects and enum singletons are widened to their underlying type. Users should not see a module class, so thats why they are included here

If the recursive part is fixed to a subtype of the union of the
cases of the enum, enable inline match to reduce cases.

Notes: this encoding could be supported by a
compiletime.Refract[S] type to split cases of a sum type.
@nicolasstucki nicolasstucki merged commit c372fa1 into scala:master Nov 30, 2020
@nicolasstucki nicolasstucki deleted the enum/recursive-gadt branch November 30, 2020 08:31
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

4 participants