reprinter-0.2.0.0: Scrap Your Reprinter

Safe HaskellNone
LanguageHaskell2010

Text.Reprinter

Synopsis

Documentation

reprintSort :: (Monad m, Data ast) => Reprinting m -> ast -> Source -> m Source Source #

The reprint algorithm takes a refactoring (parameteric in | some monad m) and turns an arbitrary pretty-printable type ast | into a monadic Source transformer.

reprint :: (Monad m, Data ast) => Reprinting m -> ast -> Source -> m Source Source #

The reprint algorithm takes a refactoring (parameteric in | some monad m) and turns an arbitrary pretty-printable type ast | into a monadic Source transformer.

type Source = Text Source #

Text from source file

type Position = (Line, Col) Source #

A position in a text (imagine a cursor)

initPosition :: Position Source #

The initial position

initLine :: Line Source #

Lines start at 1

initCol :: Col Source #

Columns start at 1

mkLine :: Int -> Either String Line Source #

Smart constructor for a Line, checks that line >= 1

mkCol :: Int -> Either String Col Source #

Smart constructor for a Col, checks that column >= 1

advanceLine :: Position -> Position Source #

Given a position, go down a line, going back to the initial column

advanceCol :: Position -> Position Source #

Given a position, advance by one column

type Span = (Position, Position) Source #

Two positions give the lower and upper bounds of a source span

type Reprinting m = forall node. Typeable node => node -> m (Maybe (RefactorType, Source, Span)) Source #

Type of a reprinting function

catchAll :: Monad m => a -> m (Maybe b) Source #

Catch all generic query

genReprinting :: (Monad m, Refactorable t, Typeable t) => (t -> m Source) -> t -> m (Maybe (RefactorType, Source, Span)) Source #

Essentially wraps the refactorable interface

class Refactorable t where Source #

Infrastructure for building the reprinter "plugins"

Minimal complete definition

isRefactored, getSpan

data RefactorType Source #

Specify a refactoring type

Constructors

Before 
After 
Replace