You can construct the free Divisible functor (free relative to the forgetful functor which only remembers the Contravariant instance) using contravariant Day convolution, just like you can construct the free Applicative using covariant Day convolution:
-- Free f ~ Coproduct Proxy (Day f (Free f))
data Free f a
= Conquer
| forall b c. Divide (a -> (b, c)) (f b) (Free f c)
So you can list out the primitive ways you would like to be able to consume values using some Contravariant functor, and then construct a Divisible functor from that. To consume an a using Free f a, you split a into a big tuple, and for each component of that tuple, either consume it using an f, or simply use conquer.
Maybe it's worth adding here?
I have a prototype implementation in PureScript here for reference.
You can construct the free
Divisible
functor (free relative to the forgetful functor which only remembers theContravariant
instance) using contravariantDay
convolution, just like you can construct the freeApplicative
using covariantDay
convolution:So you can list out the primitive ways you would like to be able to consume values using some
Contravariant
functor, and then construct aDivisible
functor from that. To consume ana
usingFree f a
, you splita
into a big tuple, and for each component of that tuple, either consume it using anf
, or simply useconquer
.Maybe it's worth adding here?
I have a prototype implementation in PureScript here for reference.