Unfolding


Identity: Unfolding
Category: MultiModule Naming
Classifiers: unfolding expression definition
Internal cross references:
External cross references:
Language: Haskell

Description:

Replace an instance of the left hand side of a definition by the corresponding right hand side. This is commonly known as unfolding or inlining, with the inverse termed folding.


showAll = table . map show
table   = concat . format
      

showAll = (concat . format) . map show
table   = concat . format

General comment:

The unfolded definition should be a function definition or a simple pattern binding. A complex function definition need to be transformed into a simple one during the refactoring.

Left to right comment:

In the example, the call to the function table is replaced by its definition.

Right to left comment:

Left to right conditions:

At the site of unfolding, the bindings for the free identifiers of the RHS of the unfolded definition (of foo, say) need to be accessible and be the same as in the definition of foo.

Automatic renaming by the refactorer is required when the bound variables in the unfolded definition capture the use of free variables at the site of unfolding, especially when the user has no right to do renaming in the unfolded definition.

Right to left conditions:

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