HaRe- the Haskell Refactorer.

Safe HaskellNone




isIgnoredNonComment :: PosToken -> BoolSource

Tokens that are ignored when determining the first non-comment token in a span

endsWithNewLn :: PosToken -> BoolSource

Returns True if the token ends with '\n' ++AZ++: is this meaningful?

startsWithNewLn :: PosToken -> BoolSource

Returns True if the token starts with `\n`. ++AZ++: is this meaningful?

compressPreNewLns :: [PosToken] -> [PosToken]Source

Remove the extra preceding empty lines.

compressEndNewLns :: [PosToken] -> [PosToken]Source

Remove the following extra empty lines.

lengthOfLastLine :: [PosToken] -> IntSource

Given a token stream covering multi-lines, calculate the length of the last line AZ: should be the last token start col, plus length of token.

getToks :: (SimpPos, SimpPos) -> [PosToken] -> [PosToken]Source

get a token stream specified by the start and end position.

replaceTokNoReAlign :: [PosToken] -> SimpPos -> PosToken -> [PosToken]Source

Replace a single token in the token stream by a new token, without adjusting the layout. Note1: does not re-align, else other later replacements may fail. Note2: must keep original end col, to know what the inter-token gap was when re-aligning

deleteToks :: [PosToken] -> SimpPos -> SimpPos -> [PosToken]Source

Delete a sequence of tokens specified by the start position and end position from the token stream, then adjust the remaining token stream to preserve layout

doRmWhites :: Int -> [PosToken] -> [PosToken]Source

remove at most n white space tokens from the beginning of ts

srcLocs :: Data t => t -> [SimpPos]Source

get all the source locations (use locations) in an AST phrase t according the the occurrence order of identifiers.

getSrcSpan :: Data t => t -> Maybe SrcSpanSource

Get the first SrcSpan found, in top down traversal

getAllSrcLocs :: Data t => t -> [(SimpPos, SimpPos)]Source

Get all the source locations in a given syntax fragment

extendForwards :: [PosToken] -> (SimpPos, SimpPos) -> (PosToken -> Bool) -> (SimpPos, SimpPos)Source

Extend the given position forwards to the end of the file while the supplied condition holds

extendBackwards :: [PosToken] -> (SimpPos, SimpPos) -> (PosToken -> Bool) -> (SimpPos, SimpPos)Source

Extend the given position backwards to the front of the file while the supplied condition holds

startEndLocIncFowComment :: Data t => [PosToken] -> t -> (SimpPos, SimpPos)Source

Get the start&end location of syntax phrase t, then extend the end location to cover the comment/white spaces or new line which starts in the same line as the end location TODO: deprecate this in favour of startEndLocIncComments

startEndLocIncComments :: Data t => [PosToken] -> t -> (SimpPos, SimpPos)Source

Get the start&end location of t in the token stream, then extend the start and end location to cover the preceding and following comments.

In this routine, 'then','else','do' and 'in' are treated as comments.

tokenise :: RealSrcLoc -> Int -> Bool -> String -> IO [PosToken]Source

Convert a string into a set of Haskell tokens, following the given position, with each line indented by a given column offset if required TODO: replace 'colOffset withFirstLineIndent' with a Maybe Int ++AZ++

basicTokenise :: String -> IO [PosToken]Source

Convert a string into a set of Haskell tokens. It has default position and offset, since it will be stitched into place in TokenUtils

getLineOffset :: [PosToken] -> SimpPos -> IntSource

Get the start of the line before the pos,

splitToks :: (SimpPos, SimpPos) -> [PosToken] -> ([PosToken], [PosToken], [PosToken])Source

Split the token stream into three parts: the tokens before the startPos, the tokens between startPos and endPos, and the tokens after endPos. Note: The startPos and endPos refer to the startPos of a token only. So a single token will have the same startPos and endPos NO^^^^

emptyList :: [t] -> BoolSource

Get around lack of instance Eq when simply testing for empty list

divideComments :: Int -> Int -> [PosToken] -> ([PosToken], [PosToken])Source

Split a set of comment tokens into the ones that belong with the startLine and those that belong with the endLine

getIndentOffset :: [PosToken] -> SimpPos -> IntSource

Get the indent of the line before, taking into account in-line 'where', 'let', 'in' and 'do' tokens

monotonicLineToks :: [PosToken] -> [PosToken]Source

sort out line numbering so that they are always monotonically increasing.

reSequenceToks :: [PosToken] -> [PosToken]Source

Adjust token stream to cater for changes in token length due to token renaming

mkToken :: Token -> SimpPos -> String -> PosTokenSource

Compose a new token using the given arguments.

markToken :: PosToken -> PosTokenSource

Mark a token so that it can be use to trigger layout checking later when the toks are retrieved

isMarked :: PosToken -> BoolSource

Does a token have the file mark in it

addOffsetToToks :: SimpPos -> [PosToken] -> [PosToken]Source

Add a constant line and column offset to a span of tokens

matchTokenPos :: PosToken -> PosToken -> PosTokenSource

Transfer the location information from the first param to the second