generics-sop icon indicating copy to clipboard operation
generics-sop copied to clipboard

Add IsSumType

Open michaelpj opened this issue 4 years ago • 4 comments

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.

michaelpj avatar Mar 05 '21 16:03 michaelpj

Ah well, that answers my question about the CI. I could stick it in some CPP, I guess.

michaelpj avatar Mar 05 '21 17:03 michaelpj

Interesting, thanks. Yes, I think this would be useful to have.

kosmikus avatar Mar 23 '21 15:03 kosmikus

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.

michaelpj avatar Jan 19 '22 17:01 michaelpj

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.

michaelpj avatar Jan 19 '22 17:01 michaelpj