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

Compiler hangs when using LabelledGeneric to convert classes #706

Closed
vitorsvieira opened this issue Apr 18, 2017 · 8 comments
Closed

Compiler hangs when using LabelledGeneric to convert classes #706

vitorsvieira opened this issue Apr 18, 2017 · 8 comments

Comments

@vitorsvieira
Copy link

vitorsvieira commented Apr 18, 2017

Hi all,

Generic and LabelledGeneric are awesome tools to "convert" classes, but unfortunately this is not true when the classes have approx. more than 10 fields. The compiler loses the track of the implicits and it hangs.

One can easily spot such behaviour by adding more fields to the example given in the Shapeless Guide and in the exercises solutions.

I was pointed to scala/scala#5649 when asking for a help on gitter and I understand that it is a work in progress, aiming to be delivered in scala 2.12.3.

For now, how to use the pattern shown in the book and in recent talks with "real world" classes?

https://github.com/underscoreio/shapeless-guide-code/tree/solutions/migrations/src/main/scala

Case Class Migration at Scala World, from Dave Gurnell

@milessabin
Copy link
Owner

I don't think this should be an issue until you get to ~30 fields ... do you have an example of a 10 field case class where the compilation time is unacceptable?

@milessabin
Copy link
Owner

Ahh ... understood. I think it's highly unlikely that the compile time cost is attributable to LabelledGeneric ... I think it's most likely the Align which is the culprit.

@Atry
Copy link
Contributor

Atry commented Jun 6, 2017

I guess a macro materializer for Align may help.

@Atry
Copy link
Contributor

Atry commented Jun 6, 2017

A macro version Align will improve not only the compiler time cost but also run time cost

@milessabin
Copy link
Owner

@Atry do you have time to investigate whether -Yinduction-heuristics in Typelevel Scala help with this one?

@fspillner
Copy link

fspillner commented May 4, 2018

I have issues with compilation speed with Align too, but only if the implicits could not be resolved (it took 15 minutes until I get the error). If I put the right type, then it compiles fast.

Additional info: My ADT contains 12 fields and is aligned with another ADT with 7 fields (with Intersection before)

@joroKr21 joroKr21 added this to the shapeless-2.4.0 milestone Mar 21, 2020
@joroKr21
Copy link
Collaborator

Should be fixed by #682 - feel free to reopen otherwise.

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

No branches or pull requests

5 participants