stylish-haskell-0.12.0.0: Haskell code prettifier

Safe HaskellNone
LanguageHaskell2010

Language.Haskell.Stylish.Printer

Contents

Synopsis

Documentation

newtype Printer a Source #

Printer that keeps state of file

Instances
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 #

fail :: String -> 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 #

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 #

MonadState PrinterState Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

MonadReader PrinterConfig Printer Source # 
Instance details

Defined in Language.Haskell.Stylish.Printer

data PrinterConfig Source #

Configuration for printer, currently empty

Constructors

PrinterConfig 

Fields

Alias

type P = Printer Source #

Shorthand for Printer monad

Functions to use the printer

runPrinter :: PrinterConfig -> [RealLocated AnnotationComment] -> Module -> Printer a -> (a, Lines) Source #

Run printer to get printed lines out of module as well as return value of monad

runPrinter_ :: PrinterConfig -> [RealLocated AnnotationComment] -> Module -> Printer a -> Lines Source #

Run printer to get printed lines only

Combinators

comma :: P () Source #

Print a comma

dot :: P () Source #

Print a dot

getAnnot :: SrcSpan -> P [AnnKeywordId] Source #

Get all annotations for SrcSpan

getCurrentLine :: P String Source #

Get current line

getCurrentLineLength :: P Int Source #

Get current line length

getDocstrPrev :: SrcSpan -> P (Maybe AnnotationComment) Source #

Get a docstring on the start line of SrcSpan that is a -- ^ comment

newline :: P () Source #

Print a newline

parenthesize :: P a -> P a Source #

Add parens around a printed action

peekNextCommentPos :: P (Maybe SrcSpan) Source #

Peek at the next comment in the state

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

Prefix a printer with another one

putComment :: AnnotationComment -> P () Source #

Print any comment

putEolComment :: SrcSpan -> P () Source #

Given the current start line of SrcSpan, remove and put EOL comment for same line

putOutputable :: Outputable a => a -> P () Source #

Print an Outputable

putAllSpanComments :: P () -> SrcSpan -> P () Source #

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

putCond :: (PrinterState -> Bool) -> P b -> P b -> P b Source #

Check condition post action, and use fallback if false

putType :: Located (HsType GhcPs) -> P () Source #

Print type

putText :: String -> P () Source #

Print text

removeCommentTo :: SrcSpan -> P [AnnotationComment] Source #

Removes comments from the state up to start line of SrcSpan and returns the ones that were removed

removeCommentToEnd :: SrcSpan -> P [AnnotationComment] Source #

Removes comments from the state up to end line of SrcSpan and returns the ones that were removed

removeLineComment :: Int -> P (Maybe AnnotationComment) Source #

Gets comment on supplied line and removes it from the state

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

Add separator between each element of the given printers

groupAttachedComments :: [Located a] -> P [([AnnotationComment], NonEmpty (Located a))] Source #

Get attached comments belonging to '[Located a]' given

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

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