`elem` applied to a known string should compile to a case expression.
Writing foo x = x
elem "abc" should compile to a case expression like
case x of 'a' -> True 'b' -> True 'c' -> True _ -> False
Case expression are in general either O(log(n)) or O(1) whereas a traversal based elem is O(n) so this can be a big performance win.
Code of this sort is particularly common for parser/lexer like code. And ghcide at some point saw double digit % reductions in runtime when doing this transformation by hand.
Ideally we would have a rule for this transformation which precedence over more general rules applying to
However there is currently no easy way to achieve this.