Add prisms or other functionality that tests a lens's applicability
Lenses can sometimes fail:
(lens-view (hash-ref-lens 'b) #hash((a . 0)))
This is especially troublesome for composed lenses that act on deeply nested structures. I'd love there to be a sort of lens-test? or lens-correct? to test a lens on some data.
Could you describe the composed lens you were working with and a broad overview of what you were trying to do with your data? There's multiple ways of handling this sort of problem, and the extra information would help.
Here are the composed lenses
https://github.com/BourgondAries/elevators/blob/master/source/lenses.rkt
Here is an example usage
https://github.com/BourgondAries/elevators/blob/master/source/utilities.rkt#L160-L162
It is sometimes possible that elevators contains no key (id) that's used in (hash-ref-lens id), and as such, this code crashes.
Ideally it'd be possible to check if the composed lens "works" on the data structure. Another possibility (specifically for hash-ref-lens) is to provide a second function that acts as a fallback/default key-value creator.
If the key isn't present, what would you like to do? Set a default key and continue? Or something else?
In the above case: Log a message and return the elevators structure unedited.
Something along the lines of
(if (lens-works? this:call elevators)
... ; do the transformation on elevators
elevators)