Progress on ‘HaRe: The Haskell Refactorer’ Huiqing Li, Claus Reinke, Simon Thompson Computing Laboratory, University of Kent Refactoring is the process.

Slides:



Advertisements
Similar presentations
ANALYSIS MODEL. Analysis Model Actual system development start with this. Aims to structure the system independently of the actual implementation environment.
Advertisements

Data Format Description Language (DFDL) WG Martin Westhead EPCC, University of Edinburgh Alan Chappell PNNL
Lilian Blot Announcements Teaching Evaluation Form week 9 practical session Formative Assessment week 10 during usual practical sessions group 1 Friday.
Merijn de Jonge IPA Spring Days 2005 April 1, 2005 Build-level Components.
HaRe The Haskell Refactorer Huiqing Li Claus Reinke Simon Thompson Computing Lab, University of Kent
Tool Support for Refactoring Functional Programs Huiqing Li Claus Reinke Simon Thompson Computing Lab, University of Kent
Huiqing Li Claus Reinke Simon Thompson Computing Lab, University of Kent Refactoring Functional Programs.
Huiqing Li Claus Reinke Simon Thompson Computing Lab, University of Kent Refactoring Functional Programs.
Tools for Refactoring Functional Programs Simon Thompson with Huiqing Li Claus Reinke
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
INSPIRE The Insieme Parallel Intermediate Representation Herbert Jordan, Peter Thoman, Simone Pellegrini, Klaus Kofler, and Thomas Fahringer University.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
CSE341: Programming Languages Lecture 16 Datatype-Style Programming With Lists or Structs Dan Grossman Winter 2013.
Refactoring Functional Programs Claus Reinke Simon Thompson TCS Seminar, 1 October 2001.
Lecture 12 – ADTs and Stacks.  Modularity  Divide the program into smaller parts  Advantages  Keeps the complexity managable  Isolates errors (parts.
Background information Formal verification methods based on theorem proving techniques and model­checking –to prove the absence of errors (in the formal.
Software Reuse Building software from reusable components Objectives
The Formalisation of Haskell Refactorings Huiqing Li Simon Thompson Computing Lab, University of Kent
Refactoring Haskell Programs Huiqing Li Computing Lab, University of Kent
WRT 2007 Refactoring Functional Programs Huiqing Li Simon Thompson Computing Lab Chris Brown Claus Reinke University of Kent.
The Structure of the GNAT Compiler. A target-independent Ada95 front-end for GCC Ada components C components SyntaxSemExpandgigiGCC AST Annotated AST.
The Haskell Refactorer, HaRe, and its API Huiqing Li Claus Reinke Simon Thompson Computing Lab, University of Kent
Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.
Refactoring Functional Programs Huiqing Li Claus Reinke Simon Thompson Computing Lab, University of Kent.
Architectural Design Establishing the overall structure of a software system Objectives To introduce architectural design and to discuss its importance.
C++ fundamentals.
Overview of Eclipse Parallel Tools Platform Adam Leko UPC Group HCS Research Laboratory University of Florida Color encoding key: Blue: Information Red:
CSE 332: C++ templates and generic programming I Motivation for Generic Programming in C++ We’ve looked at procedural programming –Reuse of code by packaging.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
Extreme Grammaring Development of an industrial strength ISO VDM-SL Grammar.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
DIY Refactorings in Wrangler Huiqing Li Simon Thompson School of Computing University of Kent.
Extensible Plug-ins for Aspect-Oriented Programming Macneil Shonle*Ankit Shah.
Phoenix Software Projects Larry Beaty © 2007 Larry Beaty. Copying and distribution of this document is permitted in any medium, provided this notice is.
Slide 1, Presentation: Reverse Engineering state diagrams from C/C++ code, | Dennie van Zeeland Masters Project Reverse Engineering state machine.
Reviewing Recent ICSE Proceedings For:.  Defining and Continuous Checking of Structural Program Dependencies  Automatic Inference of Structural Changes.
Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton February 28th, 2003 Advisor: David G. Hannay Client:
Supported by ELTE IKKK, Ericsson Hungary, in cooperation with University of Kent Erlang refactoring with relational database Anikó Víg and Tamás Nagy Supervisors:
Nick Draper 05/11/2008 Mantid Manipulation and Analysis Toolkit for ISIS data.
A Little Language for Surveys: Constructing an Internal DSL in Ruby H. Conrad Cunningham Computer and Information Science University of Mississippi.
Generative Programming. Automated Assembly Lines.
Supported by ELTE IKKK, Ericsson Hungary, in cooperation with University of Kent Erlang refactoring with relational database Anikó Víg and Tamás Nagy Supervisors:
Methodology: The AOP Refactoring Process Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton Advisor:
Refactoring Erlang Programs Huiqing Li Simon Thompson University of Kent Zoltán Horváth Eötvös Loránd Univ.
Stratego Song Zhou *Include slides from language.org/Stratego/SlidesForSoftwareGeneration2001http:// language.org/Stratego/SlidesForSoftwareGeneration2001.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
REFACTORINGREFACTORING. Realities Code evolves substantially during development Requirements changes 1%-4% per month on a project Current methodologies.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Chapter 3 Collections. Objectives  Define the concepts and terminology related to collections  Explore the basic structures of the Java Collections.
Scalable Clone Detection and Elimination for Erlang Programs Huiqing Li, Simon Thompson University of Kent Canterbury, UK.
What am I? while b != 0 if a > b a := a − b else b := b − a return a AST == Abstract Syntax Tree.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
Cross Language Clone Analysis Team 2 February 3, 2011.
Copyright © 2009 – Curt Hill Standard Template Library An Introduction.
1 COS 260 DAY 12 Tony Gauvin. 2 Agenda Questions? 5 th Mini quiz –Chapter 5 40 min Assignment 3 Due Assignment 4 will be posted later (next week) –If.
Software Development Process CS 360 Lecture 3. Software Process The software process is a structured set of activities required to develop a software.
FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University.
Formal Specification.
The architecture of the P416 compiler
Interpreters Study Semantics of Programming Languages through interpreters (Executable Specifications) cs7100(Prasad) L8Interp.
Component Based Software Engineering
Functional Programming with Java
Combining Compile-Time and Run-Time Components
6.001 SICP Interpretation Parts of an interpreter
Executable Specifications
Presentation transcript:

Progress on ‘HaRe: The Haskell Refactorer’ Huiqing Li, Claus Reinke, Simon Thompson Computing Laboratory, University of Kent Refactoring is the process of improving the design of existing code without changing their functionality. Its key characteristic is the focus on the structural change, strictly separated from changes in functionality. If applied properly, refactoring can make a program easier to understand or modify. Refactorings are ‘diffuse’ and ‘bureaucratic’ in the sense that they have an effect not only at the point where they are initiated, but also at the places where the refactored component is used. An elementary refactoring is a refactoring that can not be decomposed into simpler refactorings, whereas a composite refactoring can be decomposed into a number of elementary refactorings. The Project: Refactoring Functional Programs Tool support is considered invaluable as it is more reliable and allows refactorings to be done (and undone) easily. sum [] = 0 sum (h:t) = (+) h (sum t) main = print $ sum [1..4] sum n [] = n sum n (h:t) = (+) h (sum n t) main = print $ sum 0 [1..4] sum c n [] = n sum c n (h:t) = c h (sum c n t) main = print $ sum (+) 0 [1..4]. Explore the prospects of refactoring functional programs taking Haskell as a case-study. Build the HaRe tool to explore the practicalities of refactoring, and to support refactoring Haskell programs. What is Refactoring? A Simple Example fold c n [] = n fold c n (h:t) = c h (fold c n t) main = print $ fold (+) 0 [1..4] generalisation renaming

Structural Refactorings Rename an identifier Delete an unused function Duplicate a definition. Promote a definition to a wider scope Demote a definition to narrow its scope Unfold a definition Introduce a definition to name an identified expression Generalise a definition Add an argument to a function Remove an unused argument from a function Module Refactorings Clean the import list Make the used entities explicitly imported Add an item to the export list Remove an item from the export list Move a definition from one module to another module Data-oriented Refactorings From concrete to abstract data-type (ADT), which is a composite refactoring built from a set of primitive refactorings: Add field labels Add discriminators Add constructors Remove nested patterns Remove patterns Create ADT interface A system designed to support refactoring Haskell programs. Full Haskell 98 coverage. Integrated into two program editors: (X)Emacs and Vim. Preserves both comments and layout of refactored program. Implemented in Haskell using Programatica’s frontends and Strafunski’s generic programming technique. Driving concerns: usability and solid basis for extensions. The first version of HaRe was released in October The current version is available online at: All the implemented refactorings are now module-aware. Added new refactorings for the module system. Added data-oriented refactorings. Evolved architecture to allow the end users to define their own refactorings. HaRe: the Haskell Refactorer What’s New in HaRe? Refactorings Implemented in HaRe

Information gathering using the Programatica front-end for Haskell (lexer,parser, type checker and module analysis) Program analysis and transformation using Strafunski's generic traversal library Program rendering by extracting program source from token stream program source refactored program source HaRe preserves the comments and layout of refactored programs by making use of the white space and comment information in the token stream, as well as the location information in both the token stream and the abstract syntax tree(AST). Both the AST and the token stream are modified during the program transformation process. Snapshots of HaRe Embedded in Emacs Implementing a Refactoring After applying the ‘From concrete to abstract data type refactoring’ to the data type Tree:

Hidden token stream manipulation. RefacLocUtils is a library for token stream manipulation. Its core is a layout adjustment algorithm which keeps the program’s layout correct after a modification to the token stream. An API for program analysis and transformation. This API forms the basis for implementing primitive refactorings. Open architecture. Design your own refactorings. Composite Refactorings Elementary Refactorings RefacUtils ProgramaticaStrafunski RefacLocUtils The refactoring group at UKC: Huiqing Li Claus Reinke Simon Thompson Populate more refactorings into HaRe, such as removing duplicated code, monadification and further data-centred refactorings. Finalise the API for user-defined refactorings and further investigate the composition of refactorings. Extend HaRe to handle ‘no-source’ files. Develop proofs of correctness for a variety of the refactorings implemented in HaRe. Extend HaRe to support Haskell 98 extensions. Testing by applying HaRe to medium/large-size Haskell 98 programs. Clarify and prove concepts by formalization. The Architecture of HaRe Evaluation of HaRe Future Directions Contact Information The project is funded by EPSRC. We are grateful to Programatica ( andhttp:// Strafunski ( development teams. -- Example: Swapping the first two arguments to the function pn in the AST mod doSwap pn mod = applyTP (full_buTP (idTP `adhocTP` swapInMatch `adhocTP` swapInExp)) mod where swapInMatch ((HsMatch loc fun pats rhs ds)::HsMatchP) | pNTtoPN fun == pn = case pats of (p1:p2:ps) -> do swapInToks p1 p2 return (HsMatch loc fun (p2:p1:ps) rhs ds) _ -> error "Insufficient arguments to swap." swapInExp ((Exp (HsApp (Exp (HsApp e e1)) e2))::HsExpP) | expToPN e ==pn = do swapInToks e1 e2 return (Exp (HsApp (Exp (HsApp e e2)) e1)) swapInExp e = return e