List.member on Dict.keys/Set.toList -> Dict/Set.member
#290 opened on Feb 24, 2024
Repository metrics
- Stars
- (22 stars)
- PR merge metrics
- (PR metrics pending)
Description
What the rule should do: Replace List.member on Set.toList/Dict.keys with Set/Dict.member
What problems does it solve: Simplifying and optimizes unnecessary convertions
Example of things the rule would report:
List.member c (Dict.keys d)
--> Dict.member c d
List.member c (Set.toList d)
--> Set.member c d
Example of things the rule would not report: Since Set/Dict.member requires comparable, but List.member does not, applying this replacement to Set/Dict.empty, could lead to a type error. So therefore we should/could not replace it in that case. (But it should be caught by some other simplification rule)
List.member c (Dict.keys Dict.empty)
The above should be simplified to
False anyways, by the callOnEmptyReturnsCheck
Should this be part of the Simplify rule or should it be a new rule?
Part of Simplify
I am looking for:
- Feedback