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

ArrowChoices are Traversing. #40

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

ArrowChoices are Traversing. #40

wants to merge 3 commits into from

Conversation

Zemyla
Copy link

@Zemyla Zemyla commented Jun 25, 2016

Add functions wanderA and traverseA that work like wander and traverse' with ArrowChoices, and make WrappedArrow Traversing as well.

Zemyla added 3 commits June 24, 2016 18:42
Add functions to implement wander and traverse' for ArrowChoices; also
make WrappedArrow a Traversing.
There was another Prelude import that brought id and (.) into scope.
That was moved.
WrappedArrow p is now a Functor, Applicative, Monad, Alternative,
MonadPlus, and MonadFix for appropriate values of p, as well as an
ArrowPlus (which it wasn't before for some reason).
@sjoerdvisscher
Copy link
Contributor

This works for just (Choice p, ProductProfunctor p) too:

wander :: forall p a b s t. (Choice p, ProductProfunctor p)
  => (forall f. (Applicative f) => (a -> f b) -> s -> f t)
  -> p a b -> p s t
wander tr p = lmap (runTrav . tr tLift) go where
  go :: forall u. p (Coyo (TList a b) u) u
  go = dimap unTList (either id id) . right' $ lmap fst go **** lmap snd p

Note: this makes Costar w Traversing for Traversable w, and therefore also Strong! This should not be possible, and when I tried to ask for something impossible, I got a stack overflow. So something is fishy, it might be this whole idea, or my translation to Choice/ProductProfunctor, or just the Choice instance for Costar.

@ekmett
Copy link
Owner

ekmett commented Mar 26, 2017

The Choice Costar instance is known to be wrong.

Base automatically changed from master to main March 25, 2021 09:48
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

Successfully merging this pull request may close these issues.

3 participants