a little gem lurking in the magnolia docs: "however, there is the flexibility to provide additional type parameters or additional implicit parameters to the definition". Adding additional implicits lets you use other typeclasses in the derivation. @propensive
-
-
Replying to @davidtx
Yes, maybe I should make that clearer! The concept is that the Magnolia macro will just glue together the appropriate method calls, but doesn't require an exact signature (in the OO sense) for each implementation, as long as they have the right "shape" to be called.
1 reply 0 retweets 1 like -
Replying to @propensive @davidtx
How hard would it be to allow driving tc A for case class where each member has an instance of tc B? I had to fallback to shapeless for this ;(
2 replies 0 retweets 0 likes -
If I understand correctly, that's exactly the use case that the text
@davidtx pointed to should help with. Just put a context bound on the type parameter to your `combine` and `dispatch` implementations.1 reply 0 retweets 0 likes -
If you want, you can even have a different Magnolia generic derivation provide the implementation for the second typeclass.
1 reply 0 retweets 0 likes -
Replying to @propensive @davidtx
In my use case I would have to have def combine[T](caseClass: CaseClass[InputTC, T]): OutputTC[T] so CaseClass captures instances of one TC and produces an instance of other TC. Maybe this works right now, will have to check.
1 reply 0 retweets 0 likes -
That's a bit more complicated, but it might work, with some effort. Derivation can take place in a type-dependent context. It's not exactly the same, but have a look at this example: https://github.com/propensive/magnolia/blob/master/examples/shared/src/main/scala/show.scala …
1 reply 0 retweets 1 like -
Replying to @propensive @davidtx
You inspired me to create this: https://gist.github.com/Krever/271282ae0cddaed019fc6eec99cc7455 … so it can be done! ... but 1) its to complicated imho 2) I had to cast ;/
1 reply 0 retweets 2 likes
I'd like to spend longer looking into this... and try to remove those casts. :)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.