Add O(1) `Iso'`s for sets with map representations
Closed this issue · 2 comments
sjshuck commented
Data.Set.Lens: EDIT This is not O(1)
something :: Iso' (Set a) (Map a ())
something = iso Set.toMap Set.fromMap
Data.HashSet.Lens:
somethingElse :: Iso' (HashSet a) (HashMap a ())
somethingElse = iso HashSet.toMap HashSet.fromMap
RyanGlScott commented
sjshuck commented
Oops, yeah, looks like only HashSet <-> HashMap is O(1).
I'm actually not in favor of adding optics converting between concrete map/set types in general, mainly because of the "why are you doing that" factor. If they are computationally free, though, it becomes "well, I guess you're not really doing anything anyway".
It's just the one Iso'
, then. I propose it be called Data.HashSet.Lens.hashMap
.