Refactoring Functional Programs. Simon Thompson with Huiqing Li Claus Reinke www.cs.kent.ac.uk/projects/refactor-fp. Session 1 . Refactoring. Refactoring means changing the design or structure of a program … without changing its behaviour. Modify. Refactor.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
f 9 + 37
h x = … f 9 + 37 …
e = h 37 + 12
f 9 + 37
h y x = … y …
e = h (f 9 + 37) 37 + 12
h = …
Hide a function which is clearly subsidiary to f; clear up the namespace.
f x y = … (h y) …
h y = …
Makes h accessible to the other functions in the module and beyond.Lift / demote
Free variables: which parameters of f are used in h?
Need h not to be defined at the top level, … ,
Type of h will generally change … DMR.
Estimating the effect of a refactoring.
Move def between modules
Delete/add to exports
Make imports explicit
data type to ADT
Short-cut, warm fusion
All module aware