Skip to content

Instantly share code, notes, and snippets.

@sjoerdvisscher
Created March 24, 2017 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjoerdvisscher/778b394f23da914dab33a82ea017538c to your computer and use it in GitHub Desktop.
Save sjoerdvisscher/778b394f23da914dab33a82ea017538c to your computer and use it in GitHub Desktop.
wander for `Choice p, ProductProfunctor p`
-- based on https://github.com/ekmett/profunctors/pull/40
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
-- This makes Costar Traversing and so also Strong! Bad idea, it just hangs when it's impossible to answer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment