Add or remove an argument


Identity: AddArgument
Category: MultiModule Naming
Classifiers: argument definition
Internal cross references:
External cross references:
Language: Haskell

Description:

Add a new argument to the definition of a function or a constant. The default value of the new argument is defined at the same level as the definition.


f x = x + 17

g z = z + f x
  

f y x = x + 17

f_y = undefined

g z = z + f f_y x
  

General comment:

The choice of the position where the argument is added is not accidental: putting the argument at the beginning of the argument list means that it can be added correctly to any partial applications of the function.

Left to right comment:

The default value given to the new parameter is undefined. The default actual argument name is a fresh name created by the refactorer. The availability of the new argument to other modules should be the same as that of the refactored definition.

Right to left comment:

An argument to a function can be removed if it is not used in the definition of the function. In this example, the definition of f_y will not be removed by removing the argument y, but can be subsequently deleted.

Left to right conditions:

Adding the new formal parameter should not cause name capture/name clash.

Right to left conditions:

The argument to be removed should not be used in the definition of the function.

Analysis required: Static analysis of bindings; call graph; module analysis.