Of course, this depends on the compiler and the parameters passed to the compiler.
In this particular example, if you compile without optimizations, GHC creates the code as you wrote it, so the second version contains an id resp call. until not . This is slightly less efficient than the first version, which then only contains a call to not :
Xors.xor1 :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool [GblId, Arity=2] Xors.xor1 = \ (ds_dkm :: GHC.Types.Bool) (x_aeI :: GHC.Types.Bool) -> case ds_dkm of _ { GHC.Types.False -> x_aeI; GHC.Types.True -> GHC.Classes.not x_aeI } Xors.xor2 :: GHC.Types.Bool -> GHC.Types.Bool -> GHC.Types.Bool [GblId, Arity=1] Xors.xor2 = \ (ds_dki :: GHC.Types.Bool) -> case ds_dki of _ { GHC.Types.False -> GHC.Base.id @ GHC.Types.Bool; GHC.Types.True -> GHC.Classes.not }
(calls are still in the produced assembly, but the kernel is more readable, so I publish only this).
But with optimization, both functions are compiled with the same kernel (and from there to the same machine code),
Xors.xor2 = \ (ds_dkf :: GHC.Types.Bool) (eta_B1 :: GHC.Types.Bool) -> case ds_dkf of _ { GHC.Types.False -> eta_B1; GHC.Types.True -> case eta_B1 of _ { GHC.Types.False -> GHC.Types.True; GHC.Types.True -> GHC.Types.False } }
GHC eta - extended the second version and introduced calls on id and not , you will get a clean pattern match.
Whether the second equation is False or a wildcard has nothing to do with any version, with or without optimization.
perhaps the compiler optimizes this extra call.
If you ask him to optimize, in simple cases like this, the GHC will eliminate the extra call.
suppose this is a nontrivial function.
Here is a possible problem. If the code is nontrivial, the compiler will not be able to eliminate all the calls made by defining the function, and not all arguments are provided. GHC does a good job of this and embeds calls, however, so you need a lot of nontriviality to make GHC refuse calls to simple functions that it knows when compiling your code (it, of course, can never connect to functions that he does. I do not know how to implement compilation of the module in question.
If this is critical code, always check what code the compiler produces for the GHC corresponding -ddump-simpl flags to get the kernel created after optimizations, and -ddump-asm to get the build done.