I'm struggling with lens and zippers. Consider below code run in ghci
> import Control.Lens
> import Control.Zipper
>
> :t within (ix 1) $ zipper ([1,2,3] :: [Int])
> within (ix 1) $ zipper ([1,2,3] :: [Int])
:: Control.Monad.MonadPlus m => m (Zipper Top Int [Int] :>> Int)
Having data A t = A t
, how can I create type of zipper like: Control.Monad.MonadPlus m => m (Zipper Top Int [Int] :>> A Int)
?
I tried within (ix 1 . to A) $ zipper ([1,2,3] :: [Int])
but it gives an error:
Could not deduce (Contravariant
(Bazaar (Indexed Int) (A Int) (A Int)))
arising from a use of ‘to’
from the context (Control.Monad.MonadPlus m)
bound by the inferred type of
it :: Control.Monad.MonadPlus m =>
m (Zipper Top Int [Int] :>> A Int)
at Top level
In the second argument of ‘(.)’, namely ‘to A’
In the first argument of ‘within’, namely ‘(ix 1 . to A)’
In the expression: within (ix 1 . to A)
(\(A a) -> a)
function? Can I just pass hereundefined
if in my case it is not that obvious? – Pompidou