haskell-tools-refactor-1.0.1.2: Refactoring Tool for Haskell

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Tools.Refactor.Utils.Lists

Description

Defines operation on AST lists. AST lists carry source information so simple list modification is not enough.

Synopsis

Documentation

filterList :: SourceInfoTraversal e => (Ann e IdDom SrcTemplateStage -> Bool) -> AnnList e -> AnnList e Source #

Filters the elements of the list. By default it removes the separator before the element. Of course, if the first element is removed, the following separator is removed as well.

filterListSt :: SourceInfoTraversal e => (Ann e IdDom SrcTemplateStage -> Bool) -> AnnList e -> LocalRefactor (AnnList e) Source #

A version of filterList that cares about keeping non-removable code elements (like preprocessor pragmas)

filterListIndexedSt :: SourceInfoTraversal e => (Int -> Ann e IdDom SrcTemplateStage -> Bool) -> AnnList e -> LocalRefactor (AnnList e) Source #

A version of filterListIndexed that cares about keeping non-removable code elements (like preprocessor pragmas)

sublist :: [Int] -> [a] -> [a] Source #

Selects the given indices from a list

notSublist :: [Int] -> [a] -> [a] Source #

Selects all but the given indices from a list

insertWhere :: Bool -> Ann e IdDom SrcTemplateStage -> (Maybe (Ann e IdDom SrcTemplateStage) -> Bool) -> (Maybe (Ann e IdDom SrcTemplateStage) -> Bool) -> AnnList e -> AnnList e Source #

Inserts the element in the places where the two positioning functions (one checks the element before, one the element after) allows the placement.

insertIndex :: (Maybe (Ann e IdDom SrcTemplateStage) -> Bool) -> (Maybe (Ann e IdDom SrcTemplateStage) -> Bool) -> [Ann e IdDom SrcTemplateStage] -> Maybe Int Source #

Checks where the element will be inserted given the two positioning functions.

zipWithSeparators :: AnnList e -> [(([SourceTemplateTextElem], SrcSpan), Ann e IdDom SrcTemplateStage)] Source #

Gets the elements and separators from a list. The first separator is zipped to the second element. To the first element, the "" string is zipped.