I noticed that I frequently use flip on functions like lookup and contains from Data.Sorted{Set,Map}. I searched for my codebase and realised that 30% of usage of such functions goes with flip. This is pretty common in other codebases, e.g. in the compiler, because sometimes we operate upon known map for a collection of keys or values, so that we want map to be fixed and the rest of the arguments to vary.
So, I propose to add such flipped variants of common functions so that we cover both usecases.
I put all the added functions as public export %inline so that if there were some (postulated) properties on the existing functions, refactoring won't break anything. I also changed several implementations to use newly added functions in the lib. Some of added functions were uncurried, when needed, some were not, I did it in the most usable way in my point of view.
I also along with addition of a new item, slightly improved formatting of code in the CHANGELOG_NEXT.md file, which doesn't worth a separate PR.
Should this change go in the CHANGELOG?
[x] If this is a fix, user-facing change, a compiler change, or a new paper
implementation, I have updated CHANGELOG_NEXT.md (and potentially also
CONTRIBUTORS.md).
Description
I noticed that I frequently use
flip
on functions likelookup
andcontains
fromData.Sorted{Set,Map}
. I searched for my codebase and realised that 30% of usage of such functions goes withflip
. This is pretty common in other codebases, e.g. in the compiler, because sometimes we operate upon known map for a collection of keys or values, so that we want map to be fixed and the rest of the arguments to vary.So, I propose to add such flipped variants of common functions so that we cover both usecases.
I put all the added functions as
public export %inline
so that if there were some (postulated) properties on the existing functions, refactoring won't break anything. I also changed several implementations to use newly added functions in the lib. Some of added functions were uncurried, when needed, some were not, I did it in the most usable way in my point of view.I also along with addition of a new item, slightly improved formatting of code in the
CHANGELOG_NEXT.md
file, which doesn't worth a separate PR.Should this change go in the CHANGELOG?
CHANGELOG_NEXT.md
(and potentially alsoCONTRIBUTORS.md
).