forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
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 example #35
Open
sideeffffect
wants to merge
42
commits into
dotty-staging:typeclass-experiments
Choose a base branch
from
sideeffffect:patch-2
base: typeclass-experiments
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix example #35
sideeffffect
wants to merge
42
commits into
dotty-staging:typeclass-experiments
from
sideeffffect:patch-2
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The rules for export forwarders are changed as follows. Previously, all export forwarders were declared `final`. Now, only term members are declared `final`. Type aliases left aside. This makes it possible to export the same type member into several traits and then mix these traits in the same class. `typeclass-aggregates.scala` shows why this is essential to be able to combine multiple givens with type members. The change does not lose safety since different type aliases would in any case lead to uninstantiatable classes.
Refinements of a class parent are added as synthetic members to the inheriting class. # Conflicts: # compiler/src/dotty/tools/dotc/config/ScalaSettings.scala # compiler/src/dotty/tools/dotc/typer/Implicits.scala # compiler/src/dotty/tools/dotc/typer/Namer.scala # tests/pos/typeclass-aggregates.scala
For a tracked class parameter we add a refinement in the constructor type that the class member is the same as the parameter. E.g. ```scala class C { type T } class D(tracked val x: C) { type T = x.T } ``` This will generate the constructor type: ```scala (x1: C): D { val x: x1.type } ``` Without `tracked` the refinement would not be added. This can solve several problems with dependent class types where previously we lost track of type dependencies.
Make context bound evidence params tracked if they have types with abstract type members.
- Don't rely on ContextBoundParamName for desugaring - For the first context bound [X: B ...], use `X` as the name of the evidence parameter for `B`.
If a context bound type `T` for type parameter `A` does not have type parameters, demand evidence of type `T { type This = A }` instead.
Allow the RHS of a type def to be higher-kinded. But keep the restriction for opaque type aliases; their RHS must be fully applied. I am not sure why the restriction applies to them, but there was a test specifically about that, so there night be a reason. # Conflicts: # compiler/src/dotty/tools/dotc/typer/Typer.scala
A type implemented in a given definition can now be an infix type, without enclosing parens being necessary. By contrast, it cannot anymore be a refined type. Refined types have to be enclosed in parens. This second point aligns the dotty parser with the published syntax and the scala meta parser.
given [A: Ord] => A is Ord: ... given [A: Ord] => A is Ord as listOrd: ...
"This" suggests the meaning "the type of this", which is not the role of Self in type classes. Also Self is used in Swift and Rust, which have a similar typeclass design. # Conflicts: # compiler/src/dotty/tools/dotc/typer/Typer.scala # tests/pos/parsercombinators-arrow.scala
A definition like `given T = deferredSummon` in a trait will be expanded to an abstract given in the trait that is implemented automatically in all classes inheriting the trait.
Expand them to givens with deferred summons # Conflicts: # compiler/src/dotty/tools/dotc/ast/Desugar.scala
Make sure that any references to a synthetic evidence parameter come after that parameter is introduced.
Avoid accidental binding to self # Conflicts: # compiler/src/dotty/tools/dotc/typer/Typer.scala
The idea is that `given ... = deferred` should be the new syntax for abstract givens. These can only be defined in traits and need to be implemented in the first subclass extending the trait. If the definition of a given vals is missing, one is synthesized by an implicit search at the site of the extending class. This will free the syntax given A is TC for the more common case where we just want to implement a marker type class TC. Also allow # Conflicts: # compiler/src/dotty/tools/dotc/typer/Namer.scala
To make an abstract given with new style syntax, one needs to write `= deferred`.
If a refined type has a parent type watching some other type, the parent should not be mapped to Object. Previously, the parent counted as `isEmpty` which caused this mapping. Also: Complete and cleanup hylolib tests
…5840 Faced with given C[T]: ... (with a new line after `:`) we now classify this as new given syntax, and assume ... is a template body. If one wants to use old syntax, one can still write given C[T] : ImplementedType ... # Conflicts: # compiler/src/dotty/tools/dotc/parsing/Parsers.scala
We already reduce `R { type A = T } # A` to `T` in most situations when we create types. We now also reduce `R { val x: S } # x` to `S` if `S` is a singleton type. This will simplify types as we go to more term-dependent typing. As a concrete benefit, it will avoid several test-pickling failures due to pickling differences when using dependent types.
Exclude synthetic, unnamed context bound evidence parameters.
# Conflicts: # compiler/src/dotty/tools/dotc/typer/Typer.scala
Co-authored-by: Dale Wijnand <[email protected]>
Co-authored-by: Dale Wijnand <[email protected]>
Hello @odersky , is this how the example is intended to work? |
odersky
requested changes
Jan 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for the change to object Monoid
, of course.
There's no need to explain parser combinators so early. The full code is given later in the examples.
odersky
force-pushed
the
typeclass-experiments
branch
3 times, most recently
from
February 2, 2024 13:17
2cf69f8
to
a63e4c4
Compare
odersky
force-pushed
the
typeclass-experiments
branch
3 times, most recently
from
February 29, 2024 09:42
db16fdc
to
3857796
Compare
odersky
force-pushed
the
typeclass-experiments
branch
from
March 8, 2024 15:27
ad1ebad
to
dfb59a1
Compare
odersky
force-pushed
the
typeclass-experiments
branch
3 times, most recently
from
March 31, 2024 12:26
3fe93ce
to
dc8c708
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.