hindent-5.2.3: Extensible Haskell pretty printer

Safe Haskell | None
Language | Haskell98

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
  - psHardLimit :: !Bool
  - psEolComment :: !Bool
  }
- data Config = Config {
  - configMaxColumns :: !Int64
  - configIndentSpaces :: !Int64
  - configTrailingNewline :: !Bool
  - configSortImports :: !Bool
  - configLineBreaks :: [String]
  }
- 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 #

A pretty printing monad.

Constructors

Printer |
Fields runPrinter :: StateT PrintState (MaybeT Identity) a

Instances

Monad 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 # |
Methods fmap :: (a -> b) -> Printer a -> Printer b # (<$) :: a -> Printer b -> Printer a #
Applicative Printer # |
Methods pure :: a -> Printer a # (<*>) :: Printer (a -> b) -> Printer a -> Printer b # (*>) :: Printer a -> Printer b -> Printer b # (<*) :: Printer a -> Printer b -> Printer a #
Alternative Printer # |
Methods empty :: Printer a # (<|>) :: Printer a -> Printer a -> Printer a # some :: Printer a -> Printer [a] # many :: Printer a -> Printer [a] #
MonadPlus Printer # |
Methods mzero :: Printer a # mplus :: Printer a -> Printer a -> Printer a #
MonadState PrintState Printer # |
Methods get :: Printer PrintState # put :: PrintState -> Printer () # state :: (PrintState -> (a, PrintState)) -> Printer a #

data PrintState #

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. psHardLimit :: !Bool Bail out if we exceed current column. psEolComment :: !Bool

Instances

MonadState PrintState Printer # |
Methods get :: Printer PrintState # put :: PrintState -> Printer () # state :: (PrintState -> (a, PrintState)) -> Printer a #

data Config #

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.

Instances

FromJSON Config # |
Methods parseJSON :: Value -> Parser Config # parseJSONList :: Value -> Parser [Config] #

defaultConfig :: Config #

Default style configuration.

data NodeInfo #

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

Show NodeInfo # |
Methods showsPrec :: Int -> NodeInfo -> ShowS # show :: NodeInfo -> String # showList :: [NodeInfo] -> ShowS #

data NodeComment #

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

Eq NodeComment # |
Methods (==) :: NodeComment -> NodeComment -> Bool # (/=) :: NodeComment -> NodeComment -> Bool #
Ord NodeComment # |
Methods compare :: NodeComment -> NodeComment -> Ordering # (<) :: NodeComment -> NodeComment -> Bool # (<=) :: NodeComment -> NodeComment -> Bool # (>) :: NodeComment -> NodeComment -> Bool # (>=) :: NodeComment -> NodeComment -> Bool # max :: NodeComment -> NodeComment -> NodeComment # min :: NodeComment -> NodeComment -> NodeComment #
Show NodeComment # |
Methods showsPrec :: Int -> NodeComment -> ShowS # show :: NodeComment -> String # showList :: [NodeComment] -> ShowS #

data SomeComment #

Some comment to print.

Constructors

EndOfLine String |
MultiLine String |

Instances

Eq SomeComment # |
Methods (==) :: SomeComment -> SomeComment -> Bool # (/=) :: SomeComment -> SomeComment -> Bool #
Ord SomeComment # |
Methods compare :: SomeComment -> SomeComment -> Ordering # (<) :: SomeComment -> SomeComment -> Bool # (<=) :: SomeComment -> SomeComment -> Bool # (>) :: SomeComment -> SomeComment -> Bool # (>=) :: SomeComment -> SomeComment -> Bool # max :: SomeComment -> SomeComment -> SomeComment # min :: SomeComment -> SomeComment -> SomeComment #
Show SomeComment # |
Methods showsPrec :: Int -> SomeComment -> ShowS # show :: SomeComment -> String # showList :: [SomeComment] -> ShowS #