Implementation of iwander

Cross-post from Slack:

Hello, I wanted to know how the iwander function is implemented.
iwander defines universal quantification of f but wander also defines one. If the two types are different how is it possible to call the wander function using itr?

class (Strong p, Choice p) <= Wander p where
  wander
    :: forall s t a b
     . (forall f. Applicative f => (a -> f b) -> s -> f t)
    -> p a b
    -> p s t
iwander
  :: forall i s t a b
   . (forall f. Applicative f => (i -> a -> f b) -> s -> f t)
  -> IndexedTraversal i s t a b
iwander itr = wander (\f s -> itr (curry f) s) <<< unwrap
1 Like

Answer:

As the (forall f ...) is an argument ( itr ), iwander can pick a suitable type for f when it goes to use itr .
When iwander calls wander and passes in an argument that works forall g , it can pick the f of itr to be g .