HaRe-0.7.2.8: the Haskell Refactorer.

Safe HaskellNone

Language.Haskell.Refact.Utils.Binds

Description

This module contains a collection of program analysis and transformation functions (the API) that work over the Type Decorated AST. Most of the functions defined in the module are taken directly from the API, but in some cases are modified to work with the type decorated AST.

In particular some new functions have been added to make type decorated AST traversals easier.

In HaRe, in order to preserve the comments and layout of refactored programs, a refactoring modifies not only the AST but also the token stream, and the program source after the refactoring is extracted from the token stream rather than the AST, for the comments and layout information is kept in the token steam instead of the AST. As a consequence, a program transformation function from this API modifies both the AST and the token stream (unless explicitly stated). So when you build your own program transformations, try to use the API to do the transformation, as this can liberate you from caring about the token stream.

This type decorated API is still in development. Any suggestions and comments are very much welcome.

Documentation

hsBinds :: HsValBinds t => t -> [LHsBind Name]Source

replaceBinds :: HsValBinds t => t -> [LHsBind Name] -> tSource

getValBindSigs :: HsValBinds Name -> [LSig Name]Source

emptyValBinds :: HsValBinds NameSource

class Data t => HsValBinds t whereSource

Methods

hsValBinds :: t -> HsValBinds NameSource

Return the binds that are directly enclosed in the given syntax phrase. hsValBinds :: t -> [GHC.LHsBind GHC.Name]

replaceValBinds :: t -> HsValBinds Name -> tSource

Replace the directly enclosed bind list by the given bind list. Note: This function does not modify the token stream. replaceBinds :: t -> [GHC.LHsBind GHC.Name] -> t

hsTyDecls :: t -> [[LTyClDecl Name]]Source

Return True if the specified identifier is declared in the given syntax phrase. isDeclaredIn :: GHC.Name -> t -> Bool

Return the type class definitions that are directly enclosed in the given syntax phrase. Note: only makes sense for GHC.RenamedSource

Instances

HsValBinds Name 
HsValBinds RenamedSource 
HsValBinds [[LTyClDecl Name]] 
HsValBinds [LPat Name] 
HsValBinds [SyntaxExpr Name] 
HsValBinds [LStmt Name] 
HsValBinds [LMatch Name] 
HsValBinds [LGRHS Name] 
HsValBinds [LTyClDecl Name] 
HsValBinds [LInstDecl Name] 
HsValBinds [LFamInstDecl Name] 
HsValBinds [LSig Name] 
HsValBinds [LHsBind Name] 
HsValBinds (LHsType Name) 
HsValBinds (LPat Name) 
HsValBinds (Stmt Name) 
HsValBinds (MatchGroup Name) 
HsValBinds (Match Name) 
HsValBinds (LStmt Name) 
HsValBinds (LMatch Name) 
HsValBinds (LHsExpr Name) 
HsValBinds (LGRHS Name) 
HsValBinds (HsExpr Name) 
HsValBinds (GRHSs Name) 
HsValBinds (LTyClDecl Name) 
HsValBinds (LInstDecl Name) 
HsValBinds (LFamInstDecl Name) 
HsValBinds (HsGroup Name) 
HsValBinds (LSig Name) 
HsValBinds (LHsBinds Name) 
HsValBinds (LHsBind Name) 
HsValBinds (HsValBinds Name) 
HsValBinds (HsLocalBinds Name) 
HsValBinds (HsIPBinds Name) 
HsValBinds (HsBind Name)