estatico / scala-newtype

NewTypes for Scala with no runtime overhead
Apache License 2.0
540 stars 31 forks source link

deriving support #30

Closed fommil closed 6 years ago

fommil commented 6 years ago

hi!

I was just wondering if you did anything more on the deriving support?

Also you didn't raise a merge request against https://gitlab.com/fommil/scalaz-deriving/ so I can't see our work :smile:

carymrobbins commented 6 years ago

For sure, some other stuff took priority, but I was actually able to get things working by adding code to the plugin - https://gitlab.com/carymrobbins/scalaz-deriving/tree/newtype

Here's a branch with some fixes for newtype that make the feature above work - https://github.com/estatico/scala-newtype/tree/deriving

As it currently stands I think the remaining work needed is to prevent the companion object from extending Function when a companion is not defined.

fommil commented 6 years ago

hmm. Disabling extending the function might be very complicated to pull off, since we're just duplicating what scalac does. The right thing to do there is to use class instead of case class. (Or on your side you could remove Function if it is synthetic)

carymrobbins commented 6 years ago

Turned out to be pretty simple, let's see what you think - https://gitlab.com/fommil/scalaz-deriving/merge_requests/149