Strafunski-StrategyLib-5.0.0.5: Library for strategic programming

MaintainerRalf Laemmel, Joost Visser
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.Generics.Strafunski.StrategyLib.RefactoringTheme

Contents

Description

This module is part of StrategyLib, a library of functional strategy combinators, including combinators for generic traversal. This module defines generic refactoring functionality. See the paper "Towards Generic Refactoring" by Ralf Laemmel. See also generic-refactoring in the examples directory.

Synopsis

The abstraction interface

class (Term abstr, Eq name, Term [abstr], Term apply) => Abstraction abstr name tpe apply | abstr -> name, abstr -> tpe, abstr -> apply, apply -> name, apply -> abstr where Source

Class of abstractions

Methods

getAbstrName :: abstr -> Maybe name Source

getAbstrParas :: abstr -> Maybe [(name, tpe)] Source

getAbstrBody :: abstr -> Maybe apply Source

getApplyName :: apply -> Maybe name Source

getApplyParas :: apply -> Maybe [(name, tpe)] Source

constrAbstr :: name -> [(name, tpe)] -> apply -> Maybe abstr Source

constrApply :: name -> [(name, tpe)] -> Maybe apply Source

Removal

eliminate Source

Arguments

:: (Term prog, Abstraction abstr name tpe apply) 
=> TU [(name, tpe)] Identity

Identify declarations

-> TU [name] Identity

Identify references

-> (abstr -> Maybe abstr)

Unwrap abstraction

-> prog

Input program

-> Maybe prog

Output program

Remove an unused abstraction

Insertion

introduce Source

Arguments

:: (Term prog, Abstraction abstr name tpe apply) 
=> TU [(name, tpe)] Identity

Identify declarations

-> TU [name] Identity

Identify references

-> ([abstr] -> Maybe [abstr])

Unwrap scope with abstractions

-> abstr

Abstraction to be inserted

-> prog

Input program

-> Maybe prog

Output program

Insert a new abstraction

Generic extraction (say fold)

extract Source

Arguments

:: (Term prog, Abstraction abstr name tpe apply) 
=> TU [(name, tpe)] Identity

Identify declarations

-> TU [name] Identity

Identify references

-> (apply -> Maybe apply)

Unwrap focus

-> ([abstr] -> [abstr])

Wrap host

-> ([abstr] -> Maybe [abstr])

Unwrap host

-> ([(name, tpe)] -> apply -> Bool)

Check focus

-> name

Name for abstraction

-> prog

Input program

-> Maybe prog

Output program

Extract an abstraction