4

Is there a way to create a lens that could do a similar thing to this function?

λ> :t \f -> bitraverse f f
\f -> bitraverse f f
  :: (Applicative f, Bitraversable t) =>
     (b -> f d) -> t b b -> f (t d d)

The specific type I'm trying to satisfy at the moment is:

something :: (Applicative f, Monad m) => (a -> f a) -> (m a, m a) -> f (m (a, a))

I've been experimenting with traverseOf and both from lens but can't seem to make the types line up.

SimonF
  • 804
  • 1
  • 7
  • 14
  • 3
    I doubt it somehow, at least no “natural” implementation. If you think of `f` as `Maybe`, and `m` as `IO`, then your type signature requires that you know whether the result is `Just` or `Nothing` before running `IO`, but you need to run `IO` to get hold of the `a` to pass to the first argument which returns the `Maybe`. But I might be wrong. – Joachim Breitner Apr 14 '16 at 11:55

0 Answers0