I’m using profunctor lenses and have an
Object (Object Int) (
Assuming no knowledge of the contents this object, I’d like to access the object below the key
foo, and inside this object, modify
3. If those keys don’t exist, they should be created. My initial idea was:
set (at "foo" <<< traversed <<< at "bar") (Just 3) myobject
But that fails when I type it as
Lens' MyState (Maybe Int) (the compiler complains about a missing
Wander instance). When I type it as
Traversal' (Object (Object Int)) (Maybe Int), it type-checks, but doesn’t actually modify the object.
What’s the problem here and can this be solved with lenses?