
This question is answered in section 4.3 of the paper.
https://www.kosmikus.org/DerivingVia/deriving-via-paper.pdf
Cheers,
Matt
On Wed, Feb 6, 2019 at 1:40 PM Georgi Lyubenov
Hi!
I would like to use `DerivingVia` to do something like this: ``` import Data.Semigroup
data Four = Four Bool (Maybe Int) Bool Bool deriving (Semigroup, Monoid) via (Any, Option (First Int), Any, Any) ```
This, however, doesn't work, because `(Any, Option (First Int), Any, Any)` is not coercible to `Four`.
Even if I do ``` data Four a b c d = Four a b c d
type Concrete = Four Bool (Maybe Int) Bool Bool ``` `Concrete` is still not coercible to `(Any, Option (First Int), Any, Any)`.
This seems like a very common thing you would want to do (for me at least it pops up often, to want to have a `Monoid` instance that is just a pointwise Monoid over it's arguments (exactly the way an n-tuple is a `Monoid`). But I don't seem to be finding an easy way to do this. I am aware of `generic-deriving` but `DerivingVia` seems like it should be able to handle something like this, with only `Coercible` holding it back (?).
Thanks in advance,
======= Georgi _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.