Function equality

I decided to give it a go but as most of the times stuff is not as easy at it seems. :slight_smile:

My assumption is that we should be able to report error when using a “non applied” function in equality checks. That is assuming this always results in a runtime error. Does there exist cases when that would not give a runtime error?

Here is my attempt if someone wants to help out:

Started out copy pasting some example so yes it is a mess. :slight_smile:

It seems doable at least. My plan was: Collect all functions (that takes arguments) and collect all Expression.OperatorApplication by ==. Then compare those in the end.

Elm-review is new to me so I have not managed to store the moduleName for functions etc.

fx x = 1
fy x = 2
ffx x y = 1
ffy x y = 2

t1 = fx == fy
t2 = ffx == ffy
t3 = ffx 1 == ffy 1

The thing collecting Expression.OperatorApplication for == needs to be recursive and handle other expressions i.e. records (with functions) etc. So for above code it collects the functions for t1 and t2 but not for t3.
I am unsure if this would cover all runtime error cases though. Are there cases this would give false positives? Also @jfmengels (ignore my ignorance of how to write elm-review rule) do you have any take on if this is feasible or other input?