generics-sop
generics-sop copied to clipboard
Add IsSumType
I found myself wanting this, and it seems like an obvious complement to the tools already in this library. I'm not all that good with generics-sop yet, so quite possibly this has a nicer implementation!
The test might also be problematic, since it uses DerivingVia (but illustrates the usecase I have for this). I don't know whether the test suite runs on versions of GHC from before DerivingVia.
Ah well, that answers my question about the CI. I could stick it in some CPP, I guess.
Interesting, thanks. Yes, I think this would be useful to have.
I found myself wanting this PR again. I know that the conversion functions don't work the way you'd like, but I wonder if you'd consider accepting the suboptimal version anyway, since it seems like it's not obvious how to make it nicer.
In case it's motivating: in this case the usecase is someone adding structured logging to HLS, where there is a lot of "this log type is the sum of the log types for all the sub-components, and now I'm going to write a bunch of tedious type class instances that just delegate to each individual type", i.e. exactly the kind of boilerplate that this lets us avoid.