As discussed on reddit, you can't just lift a Lens' a b
to Lens' (Maybe a) (Maybe b)
. But for the special case Getter a b
, this is obviously possible, since it's isomorphic to a->b
. But unlike with Iso
, there appears to be no standard function to perform this lift.
What's the preferred way to do that? In cases like
someFunction $ myMap^.at(i).ꜰᴍᴀᴘGᴇᴛ(mySubGetter)
I could of course do
someFunction $ myMap^.at(i) & fmap (^.mySubGetter)
but that doesn't work as well in other applications, as when operating on a state monad.
foo <- use $ myMapInState.at(i).ꜰᴍᴀᴘGᴇᴛ(mySubGetter)