Collection of "would-be co-Applicative" formulations
This article explains Divisible as a co-Applicative
This reddit post discusses "Coapplicative".
OP proposed:
-- Poster (u/tailcalled) proposed
class (Functor f) => Coapplicative f where
copure :: f a -> a
cozip :: f (Either a b) -> Either (f a) (f b)
There was a comment on another formulation (which is very close to Decidable)
-- Comment by u/camcann
class (Contravariant f) => Inapplicative f where
nil :: f Void
contrazip :: (f a, f b) -> f (Either a b)
The best answer explains there are no clear relation between CoApplicative
and CoMonoidal
, and they're also unrelated to Comonad
.
(Contrary to the happy coincidence Applicative
is also equivalent to lax monoidal Functor
)
class Functor f => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> (f a -> f b)
class Functor f => Monoidal f where
-- equivalent to Applicative
unit :: () -> f ()
zip :: (f a, f b) -> f (a,b)
class Functor f => CoApplicative f where
copure :: f a -> a
coap :: (f a -> f b) -> f (a -> b)
class Functor f => CoMonoidal f where
-- NOT equivalent to CoApplicative
counit :: f () -> ()
cozip :: f (a,b) -> (f a, f b)
Another answer named Decisive
.
class Functor f => Decisive f where
nogood :: f Void -> Void
orwell :: f (Either s t) -> Either (f s) (f t)
This class is also mentioned in 2. Sadly the link to the details in the answer is dead now.