Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Printer a = Printer (ReaderT PrinterConfig (State PrinterState) a)
- data PrinterConfig = PrinterConfig {}
- data PrinterState = PrinterState {}
- type P = Printer
- runPrinter :: PrinterConfig -> Printer a -> (a, Lines)
- runPrinter_ :: PrinterConfig -> Printer a -> Lines
- comma :: P ()
- dot :: P ()
- getCurrentLine :: P String
- getCurrentLineLength :: P Int
- newline :: P ()
- parenthesize :: P a -> P a
- prefix :: P a -> P b -> P b
- putComment :: EpaComment -> P ()
- putMaybeLineComment :: Maybe EpaComment -> P ()
- putOutputable :: Outputable a => a -> P ()
- putCond :: (PrinterState -> Bool) -> P b -> P b -> P b
- putType :: LHsType GhcPs -> P ()
- putRdrName :: GenLocated SrcSpanAnnN RdrName -> P ()
- putText :: String -> P ()
- sep :: P a -> [P a] -> P ()
- space :: P ()
- spaces :: Int -> P ()
- suffix :: P a -> P b -> P a
- pad :: Int -> P ()
- withColumns :: Maybe Int -> P a -> P a
- modifyCurrentLine :: (String -> String) -> P ()
- wrapping :: P a -> P a -> P a
Documentation
Printer that keeps state of file
Instances
Applicative Printer Source # | |
Functor Printer Source # | |
Monad Printer Source # | |
MonadReader PrinterConfig Printer Source # | |
Defined in Language.Haskell.Stylish.Printer ask :: Printer PrinterConfig # local :: (PrinterConfig -> PrinterConfig) -> Printer a -> Printer a # reader :: (PrinterConfig -> a) -> Printer a # | |
MonadState PrinterState Printer Source # | |
Defined in Language.Haskell.Stylish.Printer get :: Printer PrinterState # put :: PrinterState -> Printer () # state :: (PrinterState -> (a, PrinterState)) -> Printer a # |
data PrinterConfig Source #
Configuration for printer, currently empty
Instances
MonadReader PrinterConfig Printer Source # | |
Defined in Language.Haskell.Stylish.Printer ask :: Printer PrinterConfig # local :: (PrinterConfig -> PrinterConfig) -> Printer a -> Printer a # reader :: (PrinterConfig -> a) -> Printer a # |
data PrinterState Source #
State of printer
Instances
MonadState PrinterState Printer Source # | |
Defined in Language.Haskell.Stylish.Printer get :: Printer PrinterState # put :: PrinterState -> Printer () # state :: (PrinterState -> (a, PrinterState)) -> Printer a # |
Alias
Functions to use the printer
runPrinter :: PrinterConfig -> Printer a -> (a, Lines) Source #
Run printer to get printed lines out of module as well as return value of monad
runPrinter_ :: PrinterConfig -> Printer a -> Lines Source #
Run printer to get printed lines only
Combinators
getCurrentLine :: P String Source #
Get current line
getCurrentLineLength :: P Int Source #
Get current line length
parenthesize :: P a -> P a Source #
Add parens around a printed action
putComment :: EpaComment -> P () Source #
Put all comments that has positions within SrcSpan
and separate by
passed P ()
Print any comment
putMaybeLineComment :: Maybe EpaComment -> P () Source #
putOutputable :: Outputable a => a -> P () Source #
Print an Outputable
putCond :: (PrinterState -> Bool) -> P b -> P b -> P b Source #
Check condition post action, and use fallback if false
putRdrName :: GenLocated SrcSpanAnnN RdrName -> P () Source #
Print a RdrName
Indent to a given number of spaces. If the current line already exceeds that number in length, nothing happens.