Does the fsharp compiler reduce redundant function compositions to null operations?

Viewed 51

Does the following expression result in any code with the fsharp compiler?

let xs = List.rev <| List.rev xs
1 Answers

No, it doesn't. You can look at the output IL on sharplab to verify what it will emit.

You can read about the kinds of optimizations to code the F# compiler does here. There are several things it optimizes with different techniques, some of which are better-documented than others.

Related