reprinter-0.3.0.0: Scrap Your Reprinter
Safe HaskellNone
LanguageHaskell2010

Text.Reprinter

Synopsis

Documentation

type Span = (Position, Position) Source #

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

type Position = (Line, Col) Source #

A position in a text (imagine a cursor)

initPosition :: Position Source #

The initial position

initCol :: Col Source #

Columns start at 1

initLine :: Line Source #

Lines start at 1

mkCol :: Int -> Either String Col Source #

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

mkLine :: Int -> Either String Line Source #

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

advanceCol :: Position -> Position Source #

Given a position, advance by one column

advanceLine :: Position -> Position Source #

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

data RefactorType Source #

Specify a refactoring type

Constructors

Before 
After 
Replace 

Instances

Instances details
Show RefactorType Source # 
Instance details

Defined in Text.Reprinter

class Refactorable t where Source #

Infrastructure for building the reprinter "plugins"

Instances

Instances details
Refactorable (Expr Bool) Source # 
Instance details

Defined in Text.Reprinter.Example

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

Type of a reprinting function

i is the input type (something with a '[Char]'-like interface)

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

Catch all generic query

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

Essentially wraps the refactorable interface

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

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

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

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