stylish-haskell-0.14.5.0: Haskell code prettifier
Safe HaskellSafe-Inferred
LanguageHaskell2010

Language.Haskell.Stylish.Printer

Synopsis

Documentation

newtype Printer a Source #

Printer that keeps state of file

Instances

Instances details
Applicative Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

Methods

pure :: a -> Printer a #

(<*>) :: Printer (a -> b) -> Printer a -> Printer b #

liftA2 :: (a -> b -> c) -> Printer a -> Printer b -> Printer c #

(*>) :: Printer a -> Printer b -> Printer b #

(<*) :: Printer a -> Printer b -> Printer a #

Functor Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

Methods

fmap :: (a -> b) -> Printer a -> Printer b #

(<$) :: a -> Printer b -> Printer a #

Monad Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

Methods

(>>=) :: Printer a -> (a -> Printer b) -> Printer b #

(>>) :: Printer a -> Printer b -> Printer b #

return :: a -> Printer a #

MonadReader PrinterConfig Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

MonadState PrinterState Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

data PrinterConfig Source #

Configuration for printer, currently empty

Constructors

PrinterConfig 

Fields

Instances

Instances details
MonadReader PrinterConfig Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

data PrinterState Source #

State of printer

Constructors

PrinterState 

Fields

Instances

Instances details
MonadState PrinterState Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

Alias

type P = Printer Source #

Shorthand for Printer monad

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

comma :: P () Source #

Print a comma

dot :: P () Source #

Print a dot

getCurrentLine :: P String Source #

Get current line

getCurrentLineLength :: P Int Source #

Get current line length

newline :: P () Source #

Print a newline

parenthesize :: P a -> P a Source #

Add parens around a printed action

prefix :: P a -> P b -> P b Source #

Prefix a printer with another one

putComment :: EpaComment -> P () Source #

Put all comments that has positions within SrcSpan and separate by passed P ()

Print any comment

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

putType :: LHsType GhcPs -> P () Source #

Print type

putText :: String -> P () Source #

Print text

sep :: P a -> [P a] -> P () Source #

Add separator between each element of the given printers

space :: P () Source #

Print a space

spaces :: Int -> P () Source #

Print a number of spaces

suffix :: P a -> P b -> P a Source #

Suffix a printer with another one

pad :: Int -> P () Source #

Indent to a given number of spaces. If the current line already exceeds that number in length, nothing happens.

Advanced combinators

withColumns :: Maybe Int -> P a -> P a Source #

wrapping Source #

Arguments

:: P a

First printer to run

-> P a

Printer to run if first printer violates max columns

-> P a

Result of either the first or the second printer