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

Scala3 array - each / index #92

Merged
merged 3 commits into from
Apr 29, 2022
Merged

Conversation

OndrejSpanel
Copy link
Contributor

@OndrejSpanel OndrejSpanel commented Apr 28, 2022

Similar to #91, Scala 3 is missing support for Array (which is not a proper Seq).

I have implemented index, but each is a bit harder, as Array needs a ClassTag for construction.

@OndrejSpanel
Copy link
Contributor Author

OndrejSpanel commented Apr 28, 2022

I have implemented each as well. To do so I had to simplify QuicklensFunctor.map, so that it always maps to the same type. It seems to me the Scala 2 version has the same limitation, therefore it should hopefully do no harm (and certainly the project still compiles and tests pass even with this more restrictive signature).

Knowing the element type stays the same, I am able to use Array.elemTag to provide the ClassTag needed for the array construction.

I am not absolutely sure if it would work properly on arrays of boxed primitive types - I am afraid casting Array.elemTag as ClassTag[A] is not really correct then.

Still I think it should be an improvement over the current version, which did not support Arrays at all.

@OndrejSpanel OndrejSpanel marked this pull request as ready for review April 28, 2022 15:25
@adamw adamw merged commit 8c19113 into softwaremill:master Apr 29, 2022
@adamw
Copy link
Member

adamw commented Apr 29, 2022

Thanks :) indeed this seems to match scala 3 behavior

@OndrejSpanel OndrejSpanel deleted the scala3-array branch December 5, 2024 07:48
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