Is it possible to map over last breadcrumb using lens?
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
import Control.Lens
import Control.Zipper
data A = AA { _aa :: A }
| AB { _ab :: B }
deriving (Show)
data B = B deriving (Show)
makeLenses ''A
makeLenses ''B
main :: IO ()
main = do
let a = AA $ AB $ B
z :: Top :>> A
z = zipper a
zAA :: Maybe (Top :>> A :>> A)
zAA = z & within aa
zAB :: Maybe (Top :>> A :>> B)
zAB = z & within (aa . ab)
return ()
I can move from Top :>> A either to Top :>> A :>> A and Top :>> A :>> B.
Having ab lens, is it possible to move from Top :>> A :>> A (zAA) to Top :>> A :>> B (zAB), without using upward - just mapping with lens over last breadcrumb?
Is it possible to map over last breadcrumb using lens?
I can move from
Top :>> A
either toTop :>> A :>> A
andTop :>> A :>> B
.Having
ab
lens, is it possible to move fromTop :>> A :>> A
(zAA
) toTop :>> A :>> B
(zAB
), without using upward - just mapping with lens over last breadcrumb?