Open jackfirth opened 8 years ago
In addition to that, rekey could even be made into a lens like this: (Edited)
> (define (rekey-lens key->new-key-lens)
(lens-zoom hash->set-lens
(set-mapper-lens (lens-zoom car-lens key->new-key-lens))))
This would need a set-mapper-lens
, which I think would have to go from sets to sets instead of sets to lists (sets to lists is what set-map
does). I opened https://github.com/jackfirth/lens/issues/200 about that.
(Edit: this pattern was replaced by the outer use of lens-zoom
)
It also occurs to me that this pattern of
(lens-thrush an-iso-lens some-transformation-lens (isomorphism-inverse an-iso-lens))
Is just like the local-transform
combinator from pict3d. It might be useful to have a lens version of that.
(Edit: lens-zoom
is now similar to a lens version of that.)
It should be easy to convert a hash to a set of key-value pairs. Note that it should create a set, not a list, because a list would introduce ordering information that wouldn't be present in the hash. Hash keys have no particular ordering, they're only guaranteed unique from each other.
This would be very useful, as it would allow for easy hash re-keying which is a task that's cumbersome with traditional non-lens functional programming manipulations: