Although the functions should be the same, there is a difference in how they are applied. The first time that isFactor defined, isFactor fully applied on the isFactor x call isFactor x . In the second definition, this is not so, because now isFactor explicitly accepts two arguments.
For GHC, minimal optimizations are enough to see this and create identical code for both, however, if you compile with -O0 -ddump-simpl , you can determine that without optimization this matters (at least with ghc-7.2. 1, YMMV with other versions).
At the first, isFactor GHC creates a single function that is passed as a predicate to "GHC.List.Filter", with calls to mod 10000000 and (==) in the lines. For the second definition, what happens is that most of the calls inside isFactor are associated with class functions and are not shared between multiple calls to isFactor . Thus, there are many excess vocabulary that are completely unnecessary.
This is almost never a problem, because even default compiler settings will optimize it, however runhaskell does not even seem to do this. However, I sometimes structured the code as someFun xy = \z -> because I knew that someFun would be partially applied, and that was the only way to keep the exchange between calls (i.e. the GHC Optimizer was not smart enough).
John l
source share