scrooge icon indicating copy to clipboard operation
scrooge copied to clipboard

Add option to generate higher-kinded-type service interface

Open henryxparker opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. A recent release has removed the higher-kinded-type (HKT) interface when generating services (i.e. it removed the option to write Service.MethodPerEndpoint as Service[Future]). This change has excluded an existing use-case described in the comments on that commit. For brevity I will paraphrase it here:

Not everyone prefers to use twitter Futures, and the HKT interface allows you to easily change to a different F. i.e. we can turn a Service[twitter.util.Future] into a Service[scala.concurrent.Future] by providing the function* twitter.util.Future => scala.concurrent.Future. That allows us to work directly in our chosen F until we need to convert everything back to twitter Futures for finagle.

Describe the solution you'd like There should be an option to generate the HKT interface for services. Either through a plugin or a flag. The main impetus behind the original commit seems to have been to reduce the total amount of generated code. Thus a plugin/flag would allow most to benefit from the reduced code volume, and allow others to use the interface if needed.

Footnotes:

  • That's technically a "Natural Transformation" (~>), not a function (=>)

henryxparker avatar Jan 18 '22 19:01 henryxparker

hey @henryxparker, our team is taking a look at this to see what we can do for you folks. we'll reach out to you when we have updates. thanks!

joybestourous avatar Feb 22 '22 19:02 joybestourous

Update on our side: we created a library for generating higher-kinded types from the scrooge output using scalafix, and an sbt plugin that does it under the hood. It's not a perfect solution, but it will work if anyone else is having the same problem. I'll leave this open in case you want to add support for higher-kinded types back into scrooge in some way, but feel free to close it.

henryxparker avatar May 08 '23 20:05 henryxparker