Which is definitely suboptimal in some cases!
I think honestly the goal should be reasoning about evaluation order statically instead of trying to find some clever argument such that laziness or strictness is clearly "correct".
Think about the function if-then-else, which you may be familiar with from your favorite language :)
if-then-else true branch1 branch2 = branch1
if-then-else false branch1 branch2 = branch2
Obviously you don't want both branches evaluated in any given invocation, and obviously you cannot remove the unused parameter. Note that the purpose is not to "save computation", since for example branch1 may be undefined if cond is false!When using a language with support for lazy evaluation, you encounter this kind of functions all the time.
if_then_else c t e =
match c with
| true -> t ()
| false -> e ()
So the question sort of becomes one of how painful thunking or anonymous function syntax is.How do you do that when the values of the other arguments determine whether or not that argument will be used?
a=1:a
main = show $ head a
With lazy evaluation, this will print "1", but with strict evaluation, this program will never terminate as it attempts to fully evaluate "a=1:a", which creates an infinite list.>But realistically, an unused parameter should probably be removed. You also have cases where a parameter is only used some of the time.
It doesn't have to be completely unused to be avoided. In a case like:
if a then b + c else c + d
a and c are always evaluated, only b or d is evaluated not both. Removal isn't an option because b and d maybe used.
Besides that, there's also not much practical gain from it, IMO. One commonly cited benefit is a function that doesn't use all of it's arguments, therefore saving computation time when they're not evaluated. But realistically, an unused parameter should probably be removed.