There should be some way to easily convert between hashes and lists
The naive approach of hash->list + list->hash doesn't work because no ordering is guaranteed, this breaks the lens laws. One possible approach:
- hash to set isomorphism where set contains pairs
- set to list isomorphism constructor that accepts an ordering procedure and promises to always return sorted lists
- assoc-list to list isomoprhism
Hash to flat list would then be hash -> set -> assoc -> list, and would require an ordering procedure to construct the isomorphism.
What would the assoc-list to list isomorphism be? Wouldn't the assoc list already be what you want?
You're right. I was thinking an assoc list to list isomorphism would be something for converting '(a 1 b 2 c 3) to '((a . 1) (b . 2) (c . 3))
This isn't really relevant for converting between hashes and lists, but an isomorphism for converting '(a 1 b 2 c 3) to '((a . 1) (b . 2) (c . 3)) is defined here as alternating->assoc-list-lens: https://github.com/jackfirth/lens/blob/master/lens-data/lens/private/isomorphism/data.rkt#L28
I put it there planning to use it for lens-join/assoc, but I never ended up using it as a lens.