zio / zio-quill

Compile-time Language Integrated Queries for Scala
https://zio.dev/zio-quill
Apache License 2.0
2.15k stars 348 forks source link

Enhancement idea: Typeprovider, code-generation on-the-fly #1351

Open Thorium opened 5 years ago

Thorium commented 5 years ago

I would want Quill to have FSharp kind of user experience where the intellisense completes the database on the fly.

That means that the code generation step should happen on-the-fly in the IDE.

Here are the Scala way to do TypeProvider features: https://docs.scala-lang.org/overviews/macros/typeproviders.html

This is the experience for the end-user:

![F# SQLProvider](https://raw.githubusercontent.com/fsprojects/SQLProvider/master/docs/files/sqlprovider.gif "F# SQLProvider")

deusaquilus commented 5 years ago

Hi @Thorium. Doing this in an IDE would require writing IDE plugins which means that we'd have to choose which IDEs to support and which not to support. Hopefully once we manage to integrate this generator, I'll post some instructions as to how to integrate it into your SBT build. I do not like thie idea of using TypeProviders because in about a year's time, Scala's entire macro system will need to be deprecated in favor of whatever they choose to do in Dotty. This will require significant parts of Quill be be re-written as it is. Any additional use of Burmako's macro system just introduces additional technical debt for us.

godenji commented 5 years ago

@deusaquilus good point re: macros, but on the plus side Dotty just implemented preliminary support for whitebox macros, so Quill will have an equally powerful macro system to work with.

Not sure how big the rewrite will be, likely substantial.

deusaquilus commented 5 years ago

Wait? Whitebox Macros? Aren't they using tasty-reflect together with inline and then maybe some kind of translation into scalameta? Is there a dotty macro system that I don't know about? We were actually going to use inline.

Skamander commented 5 years ago

@deusaquilus - this section - https://dotty.epfl.ch/docs/reference/metaprogramming/inline.html#specializing-inline-whitebox - in the Dotty documentation about a specialized form of inline was recently posted on the scala subreddit. Maybe that's what @godenji meant?