Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential additional superclass of Traversing? #72

Open
Zemyla opened this issue Jun 2, 2019 · 1 comment
Open

Potential additional superclass of Traversing? #72

Zemyla opened this issue Jun 2, 2019 · 1 comment

Comments

@Zemyla
Copy link

Zemyla commented Jun 2, 2019

Something that's Traversing should perhaps be, in addition to being Strong and Choice, also something that represents being able to go over a fixed number of values. If there were some kind of numbered Vec, I could see it going something like this:

class Profunctor p => TraversingFixed p where
  traverseFixed :: KnownNat n => p a b -> p (Vec n a) (Vec n b)

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 to x -> a for some x:

class Profunctor p => TraversingFixed p where
  traverseDist :: (Traversable f, Distributive f) => p a b -> p (f a) (f b)

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 hypothetical wander analogue of traverseFixed would go, since the point of Applicative is that it can combine an arbitrary number of fixed effects.

@phadej
Copy link
Contributor

phadej commented May 4, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants