HaRe-0.7.2.5: 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

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