Open Zemyla opened 5 years ago
Distributive
is alone is not enough. The r
in (->) r ~ f
must be ordered. In Vec n
case r ~ Fin n
, and has Enum, Bounded
instances which agree with Traversable (Vec n)
. But in general, i.e. with just Distributive
.
I think you try to generalise binary-product into "finite products". Maybe (Traversable f, Distributive f)
is a way to say that, but I'm not sure.
Something that's
Traversing
should perhaps be, in addition to beingStrong
andChoice
, also something that represents being able to go over a fixed number of values. If there were some kind of numberedVec
, I could see it going something like this:The other way I could see it happening is by using the fact that a
Distributive
always has the same number of values in it, because it's isomorphic tox -> a
for somex
:I honestly have no idea how to convert the former to the latter, though, or what to do if the
f
to be traversed is infinite, because infinite traversals in Haskell can be meaningful. I'm also not entirely sure how a hypotheticalwander
analogue oftraverseFixed
would go, since the point ofApplicative
is that it can combine an arbitrary number of fixed effects.