hindent-5.3.4: Extensible Haskell pretty printer

Safe Haskell | Safe-Inferred
Language | Haskell2010

HIndent.Types

Description

All types.

Synopsis

- newtype Printer a = Printer {
  - runPrinter :: StateT PrintState (MaybeT Identity) a
  }
- data PrintState = PrintState {
  - psIndentLevel :: !Int64
  - psOutput :: !Builder
  - psNewline :: !Bool
  - psColumn :: !Int64
  - psLine :: !Int64
  - psConfig :: !Config
  - psInsideCase :: !Bool
  - psFitOnOneLine :: !Bool
  - psEolComment :: !Bool
  }
- data Config = Config {
  - configMaxColumns :: !Int64
  - configIndentSpaces :: !Int64
  - configTrailingNewline :: !Bool
  - configSortImports :: !Bool
  - configLineBreaks :: [String]
  - configExtensions :: [Extension]
  }
- readExtension :: (Monad m, MonadFail m) => String -> m Extension
- defaultConfig :: Config
- data NodeInfo = NodeInfo {
  - nodeInfoSpan :: !SrcSpanInfo
  - nodeInfoComments :: ![NodeComment]
  }
- data NodeComment
  - = CommentSameLine SrcSpan SomeComment
  - | CommentAfterLine SrcSpan SomeComment
  - | CommentBeforeLine SrcSpan SomeComment
- data SomeComment
  - = EndOfLine String
  - | MultiLine String

# Documentation

newtype Printer a Source #

A pretty printing monad.

Constructors

Printer |

Fields

- runPrinter :: StateT PrintState (MaybeT Identity) a

#### Instances

Instances details

Alternative Printer Source # |
Instance details Defined in HIndent.Types Methods empty :: Printer a Source # (<|>) :: Printer a -> Printer a -> Printer a Source # some :: Printer a -> Printer [a] Source # many :: Printer a -> Printer [a] Source #
Applicative Printer Source # |
Instance details Defined in HIndent.Types Methods pure :: a -> Printer a Source # (<*>) :: Printer (a -> b) -> Printer a -> Printer b Source # liftA2 :: (a -> b -> c) -> Printer a -> Printer b -> Printer c Source # (*>) :: Printer a -> Printer b -> Printer b Source # (<*) :: Printer a -> Printer b -> Printer a Source #
Functor Printer Source # |
Instance details Defined in HIndent.Types Methods fmap :: (a -> b) -> Printer a -> Printer b Source # (<$) :: a -> Printer b -> Printer a Source #
Monad Printer Source # |
Instance details Defined in HIndent.Types Methods (>>=) :: Printer a -> (a -> Printer b) -> Printer b Source # (>>) :: Printer a -> Printer b -> Printer b Source # return :: a -> Printer a Source #
MonadPlus Printer Source # |
Instance details Defined in HIndent.Types Methods mzero :: Printer a Source # mplus :: Printer a -> Printer a -> Printer a Source #
MonadState PrintState Printer Source # |
Instance details Defined in HIndent.Types Methods get :: Printer PrintState Source # put :: PrintState -> Printer () Source # state :: (PrintState -> (a, PrintState)) -> Printer a Source #

data PrintState Source #

The state of the pretty printer.

Constructors

PrintState |

Fields

- psIndentLevel :: !Int64

  Current indentation level, i.e. every time there's a new-line, output this many spaces.

- psOutput :: !Builder

  The current output bytestring builder.

- psNewline :: !Bool

  Just outputted a newline?

- psColumn :: !Int64

  Current column.

- psLine :: !Int64

  Current line number.

- psConfig :: !Config

  Configuration of max colums and indentation style.

- psInsideCase :: !Bool

  Whether we're in a case statement, used for Rhs printing.

- psFitOnOneLine :: !Bool

  Bail out if we need to print beyond the current line or the maximum column.

- psEolComment :: !Bool

#### Instances

Instances details

MonadState PrintState Printer Source # |
Instance details Defined in HIndent.Types Methods get :: Printer PrintState Source # put :: PrintState -> Printer () Source # state :: (PrintState -> (a, PrintState)) -> Printer a Source #

data Config Source #

Configurations shared among the different styles. Styles may pay attention to or completely disregard this configuration.

Constructors

Config |

Fields

- configMaxColumns :: !Int64

  Maximum columns to fit code into ideally.

- configIndentSpaces :: !Int64

  How many spaces to indent?

- configTrailingNewline :: !Bool

  End with a newline.

- configSortImports :: !Bool

  Sort imports in groups.

- configLineBreaks :: [String]

  Break line when meets these operators.

- configExtensions :: [Extension]

  Extra language extensions enabled by default.

#### Instances

Instances details

FromJSON Config Source # |
Instance details Defined in HIndent.Types Methods parseJSON :: Value -> Parser Config # parseJSONList :: Value -> Parser [Config] #

readExtension :: (Monad m, MonadFail m) => String -> m Extension Source #

Parse an extension.

defaultConfig :: Config Source #

Default style configuration.

data NodeInfo Source #

Information for each node in the AST.

Constructors

NodeInfo |

Fields

- nodeInfoSpan :: !SrcSpanInfo

  Location info from the parser.

- nodeInfoComments :: ![NodeComment]

  Comments attached to this node.

#### Instances

Instances details

Show NodeInfo Source # |
Instance details Defined in HIndent.Types Methods showsPrec :: Int -> NodeInfo -> ShowS Source # show :: NodeInfo -> String Source # showList :: [NodeInfo] -> ShowS Source #

data NodeComment Source #

Comment associated with a node. `SrcSpan` is the original source span of the comment.

Constructors

CommentSameLine SrcSpan SomeComment |
CommentAfterLine SrcSpan SomeComment |
CommentBeforeLine SrcSpan SomeComment |

#### Instances

Instances details

Show NodeComment Source # |
Instance details Defined in HIndent.Types Methods showsPrec :: Int -> NodeComment -> ShowS Source # show :: NodeComment -> String Source # showList :: [NodeComment] -> ShowS Source #
Eq NodeComment Source # |
Instance details Defined in HIndent.Types Methods (==) :: NodeComment -> NodeComment -> Bool Source # (/=) :: NodeComment -> NodeComment -> Bool Source #
Ord NodeComment Source # |

Instance details

Defined in HIndent.Types

Methods

compare :: NodeComment -> NodeComment -> Ordering Source #

(<) :: NodeComment -> NodeComment -> Bool Source #

(<=) :: NodeComment -> NodeComment -> Bool Source #

(>) :: NodeComment -> NodeComment -> Bool Source #

(>=) :: NodeComment -> NodeComment -> Bool Source #

max :: NodeComment -> NodeComment -> NodeComment Source #

min :: NodeComment -> NodeComment -> NodeComment Source #

data SomeComment Source #

Some comment to print.

Constructors

EndOfLine String |
MultiLine String |

#### Instances

Instances details

Show SomeComment Source # |
Instance details Defined in HIndent.Types Methods showsPrec :: Int -> SomeComment -> ShowS Source # show :: SomeComment -> String Source # showList :: [SomeComment] -> ShowS Source #
Eq SomeComment Source # |
Instance details Defined in HIndent.Types Methods (==) :: SomeComment -> SomeComment -> Bool Source # (/=) :: SomeComment -> SomeComment -> Bool Source #
Ord SomeComment Source # |

Instance details

Defined in HIndent.Types

Methods

compare :: SomeComment -> SomeComment -> Ordering Source #

(<) :: SomeComment -> SomeComment -> Bool Source #

(<=) :: SomeComment -> SomeComment -> Bool Source #

(>) :: SomeComment -> SomeComment -> Bool Source #

(>=) :: SomeComment -> SomeComment -> Bool Source #

max :: SomeComment -> SomeComment -> SomeComment Source #

min :: SomeComment -> SomeComment -> SomeComment Source #