-
Notifications
You must be signed in to change notification settings - Fork 38
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
Document how to get data such as field names/constructors from LightTypeTag
#436
Comments
Well, if you need to extract constructors, you kinda can do it now if you run on JVM by java-reflecting the closest We might support portable constructor reflection: it's indeed possible to generate Functoids within Regarding the fields/method signatures - all the code is already there, we just need to extend the data model and handle bit more cases in the extractors. We might help you with that if you would like to make a contribution. If you want to be able to call methods reflectively, Functoids may help too, but I would advise against such idea because every new feature slows the compiler down and bloats the binary tag representation. Also, for your purposes, you might try to use i-r together with other reflection implementations (there are links in our readme). |
In README we link to other reflection libraries that do this - https://wvlet.org/airframe/docs/airframe-surface & https://github.com/gzoller/scala-reflection (we also extract constructors/methods in izumi) - you may be able to copy these macros/approaches inside slick. Documenting how to use reflection APIs is not trivial, however there are many open source examples on github that may help to understand it. @mdedetrich ^ the code you linked looks similar to code that extracts constructors in izumi, you may be able to use it as a starting point - https://github.com/7mind/izumi/blob/686da202a7d947c7424d53501ef35472825d5f80/distage/distage-core-api/src/main/scala-3/izumi/distage/constructors/ConstructorUtil.scala#L433 |
Thanks for the tips, I will wait back for a comment from the projects author |
@mdedetrich Please open up a feature request to add field names/ constructors and I will ensure it gets prioritized. |
Actually, a fair share of this is already done in izumi, I've managed to detach most of the Functoid logic from distage. It just needs some cleanup and can be moved into i-r then. |
Although its mention in README.md that
It would be good to document how to actually achieve this even if its external to
izumi-reflect
. Specifically if you are already usingizumi-reflect
, i.e.LightTypeTag
and you need to extract data such as constructors, fields etc etc on how to do that (i.e. shapeless with scala 2, generic meta programming with Scala 3 etc etc etc)The context of this issue is the PR at tminglei/slick-pg#668 , specifically trying to convert this code block https://github.com/tminglei/slick-pg/blob/dd1ec247049311c5d515e17f634259340ff7ceaa/src/main/scala/com/github/tminglei/slickpg/PgCompositeSupport.scala#L125-L152 to izumi-reflect
The text was updated successfully, but these errors were encountered: