Try this
s ^.. key "somekey" . _Array . traverse
. to (\o -> ( o ^?! key "deeperkey" . _Number
, o ^? key "otherkey" . _Number
)
)
With (^..)
to get multiple elements from the traverse
Traversal
and Array
to match on the multiple values in the "somekey"
slot. Technically the key "deeperkey"
should be allowed to fail, but based on your return type you're making strong assumptions that it doesn't---so we use (^?!)
to do the failing (^?)
without a Maybe
monad for protection.