-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Scrap Your Reprinter -- -- A datatype generic algorithm for layout-preserving refactoring @package reprinter @version 0.2.0.0 module Text.Reprinter -- | The reprint algorithm takes a refactoring (parameteric in | some monad -- m) and turns an arbitrary pretty-printable type ast | into a -- monadic Source transformer. reprintSort :: (Monad m, Data ast) => Reprinting m -> ast -> Source -> m 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 -- | Text from source file type Source = Text -- | A position in a text (imagine a cursor) type Position = (Line, Col) -- | The initial position initPosition :: Position -- | Lines start at 1 initLine :: Line -- | Columns start at 1 initCol :: Col -- | Smart constructor for a Line, checks that line >= 1 mkLine :: Int -> Either String Line -- | Smart constructor for a Col, checks that column >= 1 mkCol :: Int -> Either String Col -- | Given a position, go down a line, going back to the initial column advanceLine :: Position -> Position -- | Given a position, advance by one column advanceCol :: Position -> Position -- | Two positions give the lower and upper bounds of a source span type Span = (Position, Position) -- | Type of a reprinting function type Reprinting m = forall node. Typeable node => node -> m (Maybe (RefactorType, Source, Span)) -- | Catch all generic query catchAll :: Monad m => a -> m (Maybe b) -- | Essentially wraps the refactorable interface genReprinting :: (Monad m, Refactorable t, Typeable t) => (t -> m Source) -> t -> m (Maybe (RefactorType, Source, Span)) -- | Infrastructure for building the reprinter "plugins" class Refactorable t isRefactored :: Refactorable t => t -> Maybe RefactorType getSpan :: Refactorable t => t -> Span -- | Specify a refactoring type data RefactorType Before :: RefactorType After :: RefactorType Replace :: RefactorType instance GHC.Show.Show Text.Reprinter.RefactorType instance GHC.Show.Show Text.Reprinter.Col instance GHC.Classes.Ord Text.Reprinter.Col instance GHC.Classes.Eq Text.Reprinter.Col instance Data.Data.Data Text.Reprinter.Col instance GHC.Show.Show Text.Reprinter.Line instance GHC.Classes.Ord Text.Reprinter.Line instance GHC.Classes.Eq Text.Reprinter.Line instance Data.Data.Data Text.Reprinter.Line