ekmett/contravariant

Refine Divisble and Decidable?

paf31 opened this issue · 3 comments

paf31 commented

Have you considered pulling out divide and choose into their own classes, like Apply/Applicative and Alt/Alternative?

It seems Op r has divide and choose but not conquer and lose when r is a Semigroup but not a Monoid, for example.

I have a proof of concept here in PureScript FWIW:

purescript/purescript-contravariant#5

I think it's fine to do so in PureScript. In Haskell though, our semi-structures tend to be kind of second class citizens.

Without Semigroup as a superclass of Monoid this actually just creates more tensions between doing things right and doing things in a way compatible with base.

Finally, there is a -- admittedly far less pressing -- foundational concern. These are made 'fundamental' by looking at Day convolution, which borrows monoidal structure from the source category.

As the construction is now it has a direct analogy to a known categorical construction. With the refinement it is its own beast in some sense.

I think the best story for Haskell, today is to leave these together. When and if we get Semigroup fully integrated as a superclass of Monoid, then I'd be happy to revisit this.

As a result I'm going to leave this issue open until then.

paf31 commented

Thanks, that helps a lot. I'll leave the split in the PureScript implementation then.

I think I'm going to recant and close this anyways. We aren't likely to integrate Semiapplicative as a superclass of Applicative any time soon, so looking at this as the contravariant form of the same, I'll likely avoid doing the same here. (I previously tried using a more refined class hierarchy for Comonad than we have for Monad, it was a mess.)