Go to: Tool Homepage - Downloads - User Guide - Examples
These functions are interfaces to the HaRe Introduce New Def refactoring operation.
Introduce a new definition for the body of an equation of a given declaration.
newDefEqBodyIn f constr newname mod
: In the declaration of a function f
inthe module mod
, select the equation where the constructor constr
occurs in the pattern, and replace the body b
of this equation by newname where newname = b
(call to HaRe Introduce New Def on the body expression b
).
Note : the behavior is unspecified when several constructors occur in a pattern or when a same constructor occurs in several patterns.
Introduce a new definition for an application of a given identifier to a given number of arguments.
newDefIdentAppN f n newname mod
: find in module mod
an application of the identifier f
to n
arguments and introduce an new binding of that expression to newname
(call to HaRe Introduce New Def on the application). If f
is applied to more than n
arguments, the subexpression where f
is applied to exactly n
arguments is selected.
Note : if there is no occurence of an application of f
to at least n
arguments, then (to be completed).
Note : if more thant one occurence of such an application is found, then (to be completed).
Note : a tuple as argument is counted as a single argument.
Same as newDefIdentAppN except that the number of parameters passed to the applied function is not given: newDefIdentApp f newname mod
Same as newDefIdentApp but the occurence of a convenient application is searched in a given function.
newDefIdentAppIn g f n newname mod
: in the top-level definition of g
in module mod
, find an application of the identifier f
to n
arguments and introduce an new binding of that expression to newname
(call to HaRe Introduce New Def on the application).
See newDefIdentApp for more details.
(to be completed)
(to be completed)
(to be completed)
The operation below is a chain: it can make several calls to the HaRe Introduce New Def refactoring operation.
newDefAllEqBodiesIn f mod
introduces local definitions for the bodies of each equation of the top-level definition of f
in the module mod
.
In the module m
, in the equation concerning the constructor c
of the definition of f
, let v
be the n
th argument of the constructor c
in the pattern of the equation, generalise v
in the local definition of f'
and name x
the new argument.
The flag curry indicates whether the arguments of the constructor are curried or not to count the arguments.
In the module m
, in the equation concerning the constructor c
of the definition of f
, let v
be the n
th argument of the constructor c
in the pattern of the equation, generalise an application of f
to v
in the local definition of f'
and name x
the new argument.
In the definition of f
in the module m
, generalise the variable v
and name the new parameter x
.
In the toplevel definition of f
in module m
, generalise an application of g
to n arguments, and name it a
.
In the toplevel definition of f
in module m
, generalise an instance of n
in an application of g
, and name it a
.
Not used anymore since v0.2.
generaliseAllRecAppToPatternVariablesInAllLocalDefsIn f prefix mod
: In the recursive toplevel definition of f
in the module mod
, select expressions which are applications of f to some arguments (as many as possible) which occur inside local declarations which defined ident is prefixed by prefix
, and genrealise them (in the local definitions).
generaliseAllIdentsTopLevel f prefix newprefix mod
:
Generalise all idents starting with prefix
in the toplevel declaration of f
in mod.
Resulting new parameters are named with newprefix
suffixed with an integer.
Lift the definition of d
at the top-level. d
is declared inside the definition of f
in the module m
.
Rename t
declared at the top-level in the module m
into f'
.
Find in the top-level declaration of f
all the identifiers starting with prefix
and rename them into f
. Qualifiers will be inserted if necessary (by HaRe).
All the new names are the same (ok if they are defined in separate modules).
Find in the top-level declaration of funname
in funmod
all the identifiers named targetname
(possibly with different qualifiers) and rename them with different names starting with the given prefix newprefix
.
All the new names are different (with a same prefix).
If funname
and targetname
are the same, the occurences refering to the toplevel function being handled will not be renamed.
This operation does not come from HaRe, it is provided with Haskell View Switcher. We explain the IDE interface and the Emacs-Lisp interfaces.
(Experimental) Replace an occurence of an identifier f by an identifier g where f and g are alpha-equivalent functions declared at the top-level. The notion of alpha-equivalence is rather ad-hoc (see the source code).
Select the occurence of the identifier to replace before choosing Refactor > Ad-hoc refactorings > Replace item in the menu.
(Experimental) Replace an occurence of an identifier f in the declaration of d in the module m by the identifier g where f and g are alpha-equivalent functions declared at the top-level. The notion of alpha-equivalence is rather ad-hoc (see the source code).
Move the top-level definition of f
from module m
to module m'
.
Move all toplevel definitions with a given prefix into modules determined by the suffix of the name defined. For example, prefix_Suffix
will be moved to SuffixMod
.
Replace an instance of the identifier d
by the boy of its definition, in the body of f
in module m
. If possible, a beta-reduction is applied (see the corresponding HaRe operation).
Fold the definition of function f
of module m
(see the corresponding HaRe operation).
Select an application of the identifier f
to i arguments in m
and apply HaRe Generative Fold operation on it (a comment must be present before the affected declaration, see the HaRe operation).
Apply a generative fold on applications of g
in the top-level declaration of f
in mod
.
Remove the definition of f
in the module m
. f
must not be used elsewhere.
Remove the definition of d
which is local to f
in the module m
. f
must not be used elsewhere.
Call the Clean imports operation on the module m
(remove the useless imports).
Remove f
from the explicit exports of the module m
. f
must not be used in an other module.
This operation does not come from HaRe, it is shipped with View Switcher.
Add in cmod
an import directive for fmod
. The imported identifers are left implicit. If a potential name clash is detected, the import is made “qualified”.
Warning: This operation is under development and can break the semantics of your program. In particular, the prerequesites to allow the import to be unqualified are not validated.
These operations are not provided by HaRe but are shipped with View Switcher.
This operation performs the following transformation (left to right):
case (e1, e2, e3) of (y, p11, p12) -> b1 (y, p21, p22) -> b2 | let y = e1 in case (e2, e3) of (p11, p12) -> b1 (p21, p22) -> b2 |
Pre-condition : y
is not free in e1
, e2
, or e3
(warning, this is not checked by the implementation currently).
The patterns and the matched expression have to be tuples.
The refactoring applies when there is a same identifier at the same position in all the pattern tuples.
Input: select the whole case expression.
simplifyCasePattern f m
:
Apply the above operation on a case expression in the definition of f
in the module m
.
(to be renamed into simplifyCasePatternIn in v0.2)
This is an heterogeneous chain : it chains simplifications and deletions (within the meaning of the “forget” operation below) of the introduced local definitions.
repeatSimplifyCasePatternIn f1 clientmod
:
Repeat simplifications and deletions in the top-level declaration of f
in mod
.
This operation performs the following transformation (left to right):
f x = case (x) of p1 -> e1 p2 -> e2 | f p1 = e1 f p2 = e2 |
Also:
f x y = case (x,y) of (p11,p12) -> e1 (p21,p22) -> e2 | f p11 p12 = e1 f p21 p22 = e2 |
caseToEqIn f m
:
Select the case expression which is at the top-level of the body of the declaration of f
in the module m
and transform it into a set of equations.
(caseToEq in v0.1)
These operations are not provided by HaRe but are shipped with View Switcher.
Makes a copy of a declaration into a comment placed just above the declaration (to be used before applying Generative Fold).
duplicateTopLevelDefIntoComment f m
:
Copy the declaration of f
of the module m
.
(duplicateIntoComment in v0.1)
Deletes a comment.
rmCommentBeforeTopLevelDef f m
: Delete the comment occurring before the declaration of f
at the top-level of the module m
.
(rmCommentBefore in v0.1)
To forget a non-recursive definition consists in unfolding it wherever it is referenced, removing it from imports/exports, and deleting it.
forgetTopLevelPrefixed prefix mod
: forget (as defined above) all top-level declarations of idents starting with prefix
in module mod
.