HaRe-0.7.0.6: the Haskell Refactorer.

Safe HaskellNone

Language.Haskell.Refact.Utils.MonadFunctions

Contents

Description

 

Synopsis

Conveniences for state access

fetchToksFinal :: RefactGhc [PosToken]Source

fetch the final tokens

fetchOrigToks :: RefactGhc [PosToken]Source

fetch the pristine token stream

fetchToks :: RefactGhc [PosToken]Source

fetch the possibly modified tokens. Deprecated

TokenUtils API

replaceToken :: SrcSpan -> PosToken -> RefactGhc ()Source

Replace a token occurring in a given GHC.SrcSpan

putToksForSpan :: SrcSpan -> [PosToken] -> RefactGhc SrcSpanSource

Replace the tokens for a given GHC.SrcSpan, return new GHC.SrcSpan delimiting new tokens

getToksForSpan :: SrcSpan -> RefactGhc [PosToken]Source

Get the current tokens for a given GHC.SrcSpan.

getToksForSpanNoInv :: SrcSpan -> RefactGhc [PosToken]Source

Get the current tokens for a given GHC.SrcSpan, without checking the invariant. TODO: this should not be necessary

getToksForSpanWithIntros :: SrcSpan -> RefactGhc [PosToken]Source

Get the current tokens for a given GHC.SrcSpan, leaving out any leading 'then', 'else', 'of', 'do' or 'in' tokens

getToksBeforeSpan :: SrcSpan -> RefactGhc ReversedToksSource

Get the current tokens preceding a given GHC.SrcSpan.

putToksForPos :: (SimpPos, SimpPos) -> [PosToken] -> RefactGhc SrcSpanSource

Replace the tokens for a given GHC.SrcSpan, return GHC.SrcSpan they are placed in

putToksAfterSpan :: SrcSpan -> Positioning -> [PosToken] -> RefactGhc SrcSpanSource

Add tokens after a designated GHC.SrcSpan

putToksAfterPos :: (SimpPos, SimpPos) -> Positioning -> [PosToken] -> RefactGhc SrcSpanSource

Add tokens after a designated position

putDeclToksAfterSpan :: Data t => SrcSpan -> Located t -> Positioning -> [PosToken] -> RefactGhc (Located t)Source

Add tokens after a designated GHC.SrcSpan, and update the AST fragment to reflect it

removeToksForSpan :: SrcSpan -> RefactGhc ()Source

Remove a GHC.SrcSpan and its associated tokens

removeToksForPos :: (SimpPos, SimpPos) -> RefactGhc ()Source

Remove a GHC.SrcSpan and its associated tokens

indentDeclAndToks :: Data t => Located t -> Int -> RefactGhc (Located t)Source

Indent an AST fragment and its associated tokens by a set amount

For debugging

drawTokenTree :: String -> RefactGhc ()Source

Print the Token Tree for debug purposes

drawTokenTreeDetailed :: String -> RefactGhc ()Source

Print detailed Token Tree for debug purposes

getTokenTree :: RefactGhc (Tree Entry)Source

Get the Token Tree for debug purposes

State flags for managing generic traversals

updateToksSource

Arguments

:: Data t 
=> Located t

Old element

-> Located t

New element

-> (Located t -> [Char])

pretty printer

-> Bool

Add trailing newline if required

-> RefactGhc ()

Updates the RefactState

updateToksWithPosSource

Arguments

:: Data t 
=> (SimpPos, SimpPos)

Start and end pos of old element

-> t

New element

-> (t -> [Char])

pretty printer

-> Bool

Add trailing newline if required

-> RefactGhc ()

Updates the RefactState

For use by the tests only