StrategyLib-4.0.0.0ContentsIndex
Data.Generics.Strafunski.StrategyLib.RefactoringTheme
Portabilityportable
Stabilityexperimental
MaintainerRalf Laemmel, Joost Visser
Contents
The abstraction interface
Removal
Insertion
Generic extraction (say fold)
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
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
getAbstrName :: abstr -> Maybe name
getAbstrParas :: abstr -> Maybe [(name, tpe)]
getAbstrBody :: abstr -> Maybe apply
getApplyName :: apply -> Maybe name
getApplyParas :: apply -> Maybe [(name, tpe)]
constrAbstr :: name -> [(name, tpe)] -> apply -> Maybe abstr
constrApply :: name -> [(name, tpe)] -> Maybe apply
eliminate :: (Term prog, Abstraction abstr name tpe apply) => TU [(name, tpe)] Identity -> TU [name] Identity -> (abstr -> Maybe abstr) -> prog -> Maybe prog
introduce :: (Term prog, Abstraction abstr name tpe apply) => TU [(name, tpe)] Identity -> TU [name] Identity -> ([abstr] -> Maybe [abstr]) -> abstr -> prog -> Maybe prog
extract :: (Term prog, Abstraction abstr name tpe apply) => TU [(name, tpe)] Identity -> TU [name] Identity -> (apply -> Maybe apply) -> ([abstr] -> [abstr]) -> ([abstr] -> Maybe [abstr]) -> ([(name, tpe)] -> apply -> Bool) -> name -> prog -> Maybe prog
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
Class of abstractions
Methods
getAbstrName :: abstr -> Maybe name
getAbstrParas :: abstr -> Maybe [(name, tpe)]
getAbstrBody :: abstr -> Maybe apply
getApplyName :: apply -> Maybe name
getApplyParas :: apply -> Maybe [(name, tpe)]
constrAbstr :: name -> [(name, tpe)] -> apply -> Maybe abstr
constrApply :: name -> [(name, tpe)] -> Maybe apply
Removal
eliminate
:: (Term prog, Abstraction abstr name tpe apply)
=> TU [(name, tpe)] IdentityIdentify declarations
-> TU [name] IdentityIdentify references
-> (abstr -> Maybe abstr)Unwrap abstraction
-> progInput program
-> Maybe progOutput program
Remove an unused abstraction
Insertion
introduce
:: (Term prog, Abstraction abstr name tpe apply)
=> TU [(name, tpe)] IdentityIdentify declarations
-> TU [name] IdentityIdentify references
-> ([abstr] -> Maybe [abstr])Unwrap scope with abstractions
-> abstrAbstraction to be inserted
-> progInput program
-> Maybe progOutput program
Insert a new abstraction
Generic extraction (say fold)
extract
:: (Term prog, Abstraction abstr name tpe apply)
=> TU [(name, tpe)] IdentityIdentify declarations
-> TU [name] IdentityIdentify references
-> (apply -> Maybe apply)Unwrap focus
-> ([abstr] -> [abstr])Wrap host
-> ([abstr] -> Maybe [abstr])Unwrap host
-> ([(name, tpe)] -> apply -> Bool)Check focus
-> nameName for abstraction
-> progInput program
-> Maybe progOutput program
Extract an abstraction
Produced by Haddock version 0.8