-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | A formatter for Haskell source code
--   
--   A formatter for Haskell source code.
@package ormolu
@version 0.1.2.0

-- | Configuration options used by the tool.
module Ormolu.Config

-- | Ormolu configuration.
data Config region
Config :: ![DynOption] -> !Bool -> !Bool -> !Bool -> !region -> Config region

-- | Dynamic options to pass to GHC parser
[cfgDynOptions] :: Config region -> ![DynOption]

-- | Do formatting faster but without automatic detection of defects
[cfgUnsafe] :: Config region -> !Bool

-- | Output information useful for debugging
[cfgDebug] :: Config region -> !Bool

-- | Checks if re-formatting the result is idempotent
[cfgCheckIdempotence] :: Config region -> !Bool

-- | Region selection
[cfgRegion] :: Config region -> !region

-- | Region selection as the combination of start and end line numbers.
data RegionIndices
RegionIndices :: !Maybe Int -> !Maybe Int -> RegionIndices

-- | Start line of the region to format
[regionStartLine] :: RegionIndices -> !Maybe Int

-- | End line of the region to format
[regionEndLine] :: RegionIndices -> !Maybe Int

-- | Region selection as the length of the literal prefix and the literal
--   suffix.
data RegionDeltas
RegionDeltas :: !Int -> !Int -> RegionDeltas

-- | Prefix length in number of lines
[regionPrefixLength] :: RegionDeltas -> !Int

-- | Suffix length in number of lines
[regionSuffixLength] :: RegionDeltas -> !Int

-- | Default Config RegionIndices.
defaultConfig :: Config RegionIndices

-- | Convert RegionIndices into RegionDeltas.
regionIndicesToDeltas :: Int -> RegionIndices -> RegionDeltas

-- | A wrapper for dynamic options.
newtype DynOption
DynOption :: String -> DynOption
[unDynOption] :: DynOption -> String

-- | Convert DynOption to Located String.
dynOptionToLocatedStr :: DynOption -> Located String
instance GHC.Base.Functor Ormolu.Config.Config
instance GHC.Show.Show region => GHC.Show.Show (Ormolu.Config.Config region)
instance GHC.Classes.Eq region => GHC.Classes.Eq (Ormolu.Config.Config region)
instance GHC.Show.Show Ormolu.Config.DynOption
instance GHC.Classes.Ord Ormolu.Config.DynOption
instance GHC.Classes.Eq Ormolu.Config.DynOption
instance GHC.Show.Show Ormolu.Config.RegionDeltas
instance GHC.Classes.Eq Ormolu.Config.RegionDeltas
instance GHC.Show.Show Ormolu.Config.RegionIndices
instance GHC.Classes.Eq Ormolu.Config.RegionIndices

-- | Ormolu-specific representation of GHC annotations.
module Ormolu.Parser.Anns

-- | Ormolu-specific representation of GHC annotations.
newtype Anns
Anns :: Map RealSrcSpan [AnnKeywordId] -> Anns

-- | Empty Anns.
emptyAnns :: Anns

-- | Create Anns from PState.
mkAnns :: PState -> Anns

-- | Lookup AnnKeywordIds corresponding to a given SrcSpan.
lookupAnns :: SrcSpan -> Anns -> [AnnKeywordId]
instance GHC.Classes.Eq Ormolu.Parser.Anns.Anns

-- | A module for parsing of pragmas from comments.
module Ormolu.Parser.Pragma

-- | Ormolu's representation of pragmas.
data Pragma

-- | Language pragma
PragmaLanguage :: [String] -> Pragma

-- | GHC options pragma
PragmaOptionsGHC :: String -> Pragma

-- | Haddock options pragma
PragmaOptionsHaddock :: String -> Pragma

-- | Extract a pragma from a comment if possible, or return Nothing
--   otherwise.
parsePragma :: String -> Maybe Pragma
instance GHC.Classes.Eq Ormolu.Parser.Pragma.Pragma
instance GHC.Show.Show Ormolu.Parser.Pragma.Pragma

-- | A module for dealing with shebangs.
module Ormolu.Parser.Shebang

-- | A wrapper for a shebang.
newtype Shebang
Shebang :: Located String -> Shebang

-- | Extract shebangs from the beginning of a comment stream.
extractShebangs :: [Located String] -> ([Shebang], [Located String])

-- | Return True if given String is a shebang.
isShebang :: String -> Bool
instance Data.Data.Data Ormolu.Parser.Shebang.Shebang
instance GHC.Classes.Eq Ormolu.Parser.Shebang.Shebang

-- | Build span stream from AST.
module Ormolu.Printer.SpanStream

-- | A stream of RealSrcSpans in ascending order. This allows us to
--   tell e.g. whether there is another "located" element of AST between
--   current element and comment we're considering for printing.
newtype SpanStream
SpanStream :: [RealSrcSpan] -> SpanStream

-- | Create SpanStream from a data structure containing "located"
--   elements.
mkSpanStream :: Data a => a -> SpanStream
instance GHC.Base.Monoid Ormolu.Printer.SpanStream.SpanStream
instance GHC.Base.Semigroup Ormolu.Printer.SpanStream.SpanStream
instance Data.Data.Data Ormolu.Printer.SpanStream.SpanStream
instance GHC.Show.Show Ormolu.Printer.SpanStream.SpanStream
instance GHC.Classes.Eq Ormolu.Printer.SpanStream.SpanStream

-- | Common definitions for pre- and post- processing.
module Ormolu.Processing.Common

-- | Ormolu state.
data OrmoluState

-- | Enabled
OrmoluEnabled :: OrmoluState

-- | Disabled
OrmoluDisabled :: OrmoluState

-- | Marker for the beginning of the region where Ormolu should be
--   disabled.
startDisabling :: IsString s => s

-- | Marker for the end of the region where Ormolu should be disabled.
endDisabling :: IsString s => s
instance GHC.Show.Show Ormolu.Processing.Common.OrmoluState
instance GHC.Classes.Eq Ormolu.Processing.Common.OrmoluState

-- | Support for CPP.
module Ormolu.Processing.Cpp

-- | State of the CPP processor.
data State

-- | Outside of CPP directives
Outside :: State

-- | In a conditional expression
InConditional :: State

-- | In a continuation (after \)
InContinuation :: State

-- | Automatically mask the line when needed and update the State.
processLine :: String -> State -> (String, State)

-- | If the given line is masked, unmask it. Otherwise return the line
--   unchanged.
unmaskLine :: Text -> Text
instance GHC.Show.Show Ormolu.Processing.Cpp.State
instance GHC.Classes.Eq Ormolu.Processing.Cpp.State

-- | Postprocessing for the results of printing.
module Ormolu.Processing.Postprocess

-- | Postprocess output of the formatter.
postprocess :: Int -> Text -> Text

-- | Preprocessing for input source code.
module Ormolu.Processing.Preprocess

-- | Transform given input possibly returning comments extracted from it.
--   This handles LINE pragmas, CPP, shebangs, and the magic comments for
--   enabling/disabling of Ormolu.
preprocess :: FilePath -> String -> RegionDeltas -> (String, String, String, [Located String])

-- | Random utilities used by the code.
module Ormolu.Utils

-- | Relative positions in a list.
data RelativePos
SinglePos :: RelativePos
FirstPos :: RelativePos
MiddlePos :: RelativePos
LastPos :: RelativePos

-- | Attach RelativePoses to elements of a given list.
attachRelativePos :: [a] -> [(RelativePos, a)]

-- | Combine all source spans from the given list.
combineSrcSpans' :: NonEmpty SrcSpan -> SrcSpan

-- | Placeholder for things that are not yet implemented.
notImplemented :: String -> a

-- | Pretty-print an Outputable thing.
showOutputable :: Outputable o => o -> String

-- | Split and normalize a doc string. The result is a list of lines that
--   make up the comment.
splitDocString :: HsDocString -> [Text]

-- | Get LHsType out of LHsTypeArg.
typeArgToType :: LHsTypeArg p -> LHsType p

-- | Get RealSrcSpan out of SrcSpan if the span is “helpful”.
unSrcSpan :: SrcSpan -> Maybe RealSrcSpan

-- | Increment line number in a SrcSpan.
incSpanLine :: Int -> SrcSpan -> SrcSpan

-- | Do two declarations have a blank between them?
separatedByBlank :: (a -> SrcSpan) -> a -> a -> Bool

-- | Do two declaration groups have a blank between them?
separatedByBlankNE :: (a -> SrcSpan) -> NonEmpty a -> NonEmpty a -> Bool

-- | Return True if one span ends on the same line the second one
--   starts.
onTheSameLine :: SrcSpan -> SrcSpan -> Bool

-- | Remove indentation from a given String. Return the input with
--   indentation removed and the detected indentation level.
removeIndentation :: String -> (String, Int)
instance GHC.Show.Show Ormolu.Utils.RelativePos
instance GHC.Classes.Eq Ormolu.Utils.RelativePos

-- | This module helps handle operator chains composed of different
--   operators that may have different precedence and fixities.
module Ormolu.Printer.Operators

-- | Intermediate representation of operator trees. It has two type
--   parameters: ty is the type of sub-expressions, while
--   op is the type of operators.
data OpTree ty op
OpNode :: ty -> OpTree ty op
OpBranch :: OpTree ty op -> op -> OpTree ty op -> OpTree ty op

-- | Return combined SrcSpans of all elements in this OpTree.
opTreeLoc :: OpTree (Located a) b -> SrcSpan

-- | Re-associate an OpTree taking into account automagically
--   inferred relative precedence of operators. Users are expected to first
--   construct an initial OpTree, then re-associate it using this
--   function before printing.
reassociateOpTree :: (op -> Maybe RdrName) -> OpTree (Located ty) (Located op) -> OpTree (Located ty) (Located op)
instance GHC.Classes.Ord Ormolu.Printer.Operators.Score
instance GHC.Classes.Eq Ormolu.Printer.Operators.Score

-- | Functions for working with comment stream.
module Ormolu.Parser.CommentStream

-- | A stream of RealLocated Comments in ascending order with
--   respect to beginning of corresponding spans.
newtype CommentStream
CommentStream :: [RealLocated Comment] -> CommentStream

-- | Create CommentStream from PState. The pragmas and
--   shebangs are removed from the CommentStream. Shebangs are only
--   extracted from the comments that come from the first argument.
mkCommentStream :: String -> [Located String] -> PState -> (Maybe (RealLocated Comment), [Shebang], [([RealLocated Comment], Pragma)], CommentStream)

-- | Pretty-print a CommentStream.
showCommentStream :: CommentStream -> String

-- | A wrapper for a single comment. The Bool indicates whether
--   there were atoms before beginning of the comment in the original
--   input. The NonEmpty list inside contains lines of multiline
--   comment {- … -} or just single item/line otherwise.
data Comment
Comment :: Bool -> NonEmpty String -> Comment

-- | Get a collection of lines from a Comment.
unComment :: Comment -> NonEmpty String

-- | Check whether the Comment had some non-whitespace atoms in
--   front of it in the original input.
hasAtomsBefore :: Comment -> Bool

-- | Is this comment multiline-style?
isMultilineComment :: Comment -> Bool
instance GHC.Base.Monoid Ormolu.Parser.CommentStream.CommentStream
instance GHC.Base.Semigroup Ormolu.Parser.CommentStream.CommentStream
instance Data.Data.Data Ormolu.Parser.CommentStream.CommentStream
instance GHC.Classes.Eq Ormolu.Parser.CommentStream.CommentStream
instance Data.Data.Data Ormolu.Parser.CommentStream.Comment
instance GHC.Show.Show Ormolu.Parser.CommentStream.Comment
instance GHC.Classes.Eq Ormolu.Parser.CommentStream.Comment

-- | In most cases import Ormolu.Printer.Combinators instead, these
--   functions are the low-level building blocks and should not be used on
--   their own. The R monad is re-exported from
--   Ormolu.Printer.Combinators as well.
module Ormolu.Printer.Internal

-- | The R monad hosts combinators that allow us to describe how to
--   render AST.
data R a

-- | Run an R monad.
runR :: R () -> SpanStream -> CommentStream -> Anns -> Bool -> Text

-- | Output a fixed Text fragment. The argument may not contain any
--   line breaks. txt is used to output all sorts of “fixed” bits of
--   syntax like keywords and pipes | in functional dependencies.
--   
--   To separate various bits of syntax with white space use space
--   instead of txt " ". To output Outputable
--   Haskell entities like numbers use atom.
txt :: Text -> R ()

-- | Similar to txt but the text inserted this way is assumed to
--   break the “link” between the preceding atom and its pending comments.
interferingTxt :: Text -> R ()

-- | Output Outputable fragment of AST. This can be used to output
--   numeric literals and similar. Everything that doesn't have inner
--   structure but does have an Outputable instance.
atom :: Outputable a => a -> R ()

-- | This primitive does not necessarily output a space. It just
--   ensures that the next thing that will be printed on the same line will
--   be separated by a single space from the previous output. Using this
--   combinator twice results in at most one space.
--   
--   In practice this design prevents trailing white space and makes it
--   hard to output more than one delimiting space in a row, which is what
--   we usually want.
space :: R ()

-- | Output a newline. First time newline is used after some
--   non-newline output it gets inserted immediately. Second use of
--   newline does not output anything but makes sure that the next
--   non-white space output will be prefixed by a newline. Using
--   newline more than twice in a row has no effect. Also, using
--   newline at the very beginning has no effect, this is to avoid
--   leading whitespace.
--   
--   Similarly to space, this design prevents trailing newlines and
--   makes it hard to output more than one blank newline in a row.
newline :: R ()

-- | Return True if we should print record dot syntax.
useRecordDot :: R Bool

-- | Increase indentation level by one indentation step for the inner
--   computation. inci should be used when a part of code must be
--   more indented relative to the parts outside of inci in order
--   for the output to be valid Haskell. When layout is single-line there
--   is no obvious effect, but with multi-line layout correct indentation
--   levels matter.
inci :: R () -> R ()

-- | Set indentation level for the inner computation equal to current
--   column. This makes sure that the entire inner block is uniformly
--   "shifted" to the right.
sitcc :: R () -> R ()

-- | Layout options.
data Layout

-- | Put everything on single line
SingleLine :: Layout

-- | Use multiple lines
MultiLine :: Layout

-- | Set Layout for internal computation.
enterLayout :: Layout -> R () -> R ()

-- | Do one or another thing depending on current Layout.
vlayout :: R a -> R a -> R a

-- | Get current Layout.
getLayout :: R Layout

-- | Make the inner computation use braces around single-line layouts.
useBraces :: R () -> R ()

-- | Make the inner computation omit braces around single-line layouts.
dontUseBraces :: R () -> R ()

-- | Return True if we can use braces in this context.
canUseBraces :: R Bool

-- | Modes for rendering of pending comments.
data CommentPosition

-- | Put the comment on the same line
OnTheSameLine :: CommentPosition

-- | Put the comment on next line
OnNextLine :: CommentPosition

-- | Register a comment line for outputting. It will be inserted right
--   before next newline. When the comment goes after something else on the
--   same line, a space will be inserted between preceding text and the
--   comment when necessary.
registerPendingCommentLine :: CommentPosition -> Text -> R ()

-- | Drop elements that begin before or at the same place as given
--   SrcSpan.
trimSpanStream :: RealSrcSpan -> R ()

-- | Get location of next element in AST.
nextEltSpan :: R (Maybe RealSrcSpan)

-- | Pop a Comment from the CommentStream if given predicate
--   is satisfied and there are comments in the stream.
popComment :: (RealLocated Comment -> Bool) -> R (Maybe (RealLocated Comment))

-- | Get the first enclosing RealSrcSpan that satisfies given
--   predicate.
getEnclosingSpan :: (RealSrcSpan -> Bool) -> R (Maybe RealSrcSpan)

-- | Set RealSrcSpan of enclosing span for the given computation.
withEnclosingSpan :: RealSrcSpan -> R () -> R ()

-- | Get spans on this line so far.
thisLineSpans :: R [RealSrcSpan]

-- | An auxiliary marker for keeping track of last output element.
data SpanMark

-- | Haddock comment
HaddockSpan :: HaddockStyle -> RealSrcSpan -> SpanMark

-- | Non-haddock comment
CommentSpan :: RealSrcSpan -> SpanMark

-- | A statement in a do-block and such span
StatementSpan :: RealSrcSpan -> SpanMark

-- | Project RealSrcSpan from SpanMark.
spanMarkSpan :: SpanMark -> RealSrcSpan

-- | Haddock string style.
data HaddockStyle

-- | 
--   -- |
--   
Pipe :: HaddockStyle

-- | 
--   -- ^
--   
Caret :: HaddockStyle

-- | 
--   -- *
--   
Asterisk :: Int -> HaddockStyle

-- | 
--   -- $
--   
Named :: String -> HaddockStyle

-- | Set span of last output comment.
setSpanMark :: SpanMark -> R ()

-- | Get span of last output comment.
getSpanMark :: R (Maybe SpanMark)

-- | For a given span return AnnKeywordIds associated with it.
getAnns :: SrcSpan -> R [AnnKeywordId]
instance GHC.Base.Monad Ormolu.Printer.Internal.R
instance GHC.Base.Applicative Ormolu.Printer.Internal.R
instance GHC.Base.Functor Ormolu.Printer.Internal.R
instance GHC.Classes.Eq Ormolu.Printer.Internal.SpitType
instance GHC.Show.Show Ormolu.Printer.Internal.SpitType
instance GHC.Show.Show Ormolu.Printer.Internal.CommentPosition
instance GHC.Classes.Eq Ormolu.Printer.Internal.CommentPosition
instance GHC.Show.Show Ormolu.Printer.Internal.Layout
instance GHC.Classes.Eq Ormolu.Printer.Internal.Layout
instance GHC.Show.Show Ormolu.Printer.Internal.RequestedDelimiter
instance GHC.Classes.Eq Ormolu.Printer.Internal.RequestedDelimiter

-- | Helpers for formatting of comments. This is low-level code, use
--   Ormolu.Printer.Combinators unless you know what you are doing.
module Ormolu.Printer.Comments

-- | Output all preceding comments for an element at given location.
spitPrecedingComments :: RealSrcSpan -> R ()

-- | Output all comments following an element at given location.
spitFollowingComments :: RealSrcSpan -> R ()

-- | Output all remaining comments in the comment stream.
spitRemainingComments :: R ()

-- | Output a Comment immediately. This is a low-level printing
--   function.
spitCommentNow :: RealSrcSpan -> Comment -> R ()

-- | Output a Comment at the end of correct line or after it
--   depending on CommentPosition. Used for comments that may
--   potentially follow on the same line as something we just rendered, but
--   not immediately after it.
spitCommentPending :: CommentPosition -> RealSrcSpan -> Comment -> R ()

-- | Printing combinators. The definitions here are presented in such an
--   order so you can just go through the Haddocks and by the end of the
--   file you should have a pretty good idea how to program rendering
--   logic.
module Ormolu.Printer.Combinators

-- | The R monad hosts combinators that allow us to describe how to
--   render AST.
data R a

-- | Run an R monad.
runR :: R () -> SpanStream -> CommentStream -> Anns -> Bool -> Text

-- | For a given span return AnnKeywordIds associated with it.
getAnns :: SrcSpan -> R [AnnKeywordId]

-- | Get the first enclosing RealSrcSpan that satisfies given
--   predicate.
getEnclosingSpan :: (RealSrcSpan -> Bool) -> R (Maybe RealSrcSpan)

-- | Output a fixed Text fragment. The argument may not contain any
--   line breaks. txt is used to output all sorts of “fixed” bits of
--   syntax like keywords and pipes | in functional dependencies.
--   
--   To separate various bits of syntax with white space use space
--   instead of txt " ". To output Outputable
--   Haskell entities like numbers use atom.
txt :: Text -> R ()

-- | Output Outputable fragment of AST. This can be used to output
--   numeric literals and similar. Everything that doesn't have inner
--   structure but does have an Outputable instance.
atom :: Outputable a => a -> R ()

-- | This primitive does not necessarily output a space. It just
--   ensures that the next thing that will be printed on the same line will
--   be separated by a single space from the previous output. Using this
--   combinator twice results in at most one space.
--   
--   In practice this design prevents trailing white space and makes it
--   hard to output more than one delimiting space in a row, which is what
--   we usually want.
space :: R ()

-- | Output a newline. First time newline is used after some
--   non-newline output it gets inserted immediately. Second use of
--   newline does not output anything but makes sure that the next
--   non-white space output will be prefixed by a newline. Using
--   newline more than twice in a row has no effect. Also, using
--   newline at the very beginning has no effect, this is to avoid
--   leading whitespace.
--   
--   Similarly to space, this design prevents trailing newlines and
--   makes it hard to output more than one blank newline in a row.
newline :: R ()

-- | Increase indentation level by one indentation step for the inner
--   computation. inci should be used when a part of code must be
--   more indented relative to the parts outside of inci in order
--   for the output to be valid Haskell. When layout is single-line there
--   is no obvious effect, but with multi-line layout correct indentation
--   levels matter.
inci :: R () -> R ()

-- | Indent the inner expression if the first argument is True.
inciIf :: Bool -> R () -> R ()

-- | Enter a Located entity. This combinator handles outputting
--   comments and sets layout (single-line vs multi-line) for the inner
--   computation. Roughly, the rule for using located is that every
--   time there is a Located wrapper, it should be “discharged” with
--   a corresponding located invocation.
located :: Located a -> (a -> R ()) -> R ()

-- | A version of located with arguments flipped.
located' :: (a -> R ()) -> Located a -> R ()

-- | Set layout according to combination of given SrcSpans for a
--   given. Use this only when you need to set layout based on e.g.
--   combined span of several elements when there is no corresponding
--   Located wrapper provided by GHC AST. It is relatively rare that
--   this one is needed.
--   
--   Given empty list this function will set layout to single line.
switchLayout :: [SrcSpan] -> R () -> R ()

-- | Layout options.
data Layout

-- | Put everything on single line
SingleLine :: Layout

-- | Use multiple lines
MultiLine :: Layout

-- | Do one or another thing depending on current Layout.
vlayout :: R a -> R a -> R a

-- | Get current Layout.
getLayout :: R Layout

-- | Insert a space if enclosing layout is single-line, or newline if it's
--   multiline.
--   
--   
--   breakpoint = vlayout space newline
--   
breakpoint :: R ()

-- | Similar to breakpoint but outputs nothing in case of
--   single-line layout.
--   
--   
--   breakpoint' = vlayout (return ()) newline
--   
breakpoint' :: R ()

-- | Render a collection of elements inserting a separator between them.
sep :: R () -> (a -> R ()) -> [a] -> R ()

-- | Render a collection of elements layout-sensitively using given
--   printer, inserting semicolons if necessary and respecting
--   useBraces and dontUseBraces combinators.
--   
--   
--   useBraces $ sepSemi txt ["foo", "bar"]
--     == vlayout (txt "{ foo; bar }") (txt "foo\nbar")
--   
--   
--   
--   dontUseBraces $ sepSemi txt ["foo", "bar"]
--     == vlayout (txt "foo; bar") (txt "foo\nbar")
--   
sepSemi :: (a -> R ()) -> [a] -> R ()

-- | Return True if we can use braces in this context.
canUseBraces :: R Bool

-- | Make the inner computation use braces around single-line layouts.
useBraces :: R () -> R ()

-- | Make the inner computation omit braces around single-line layouts.
dontUseBraces :: R () -> R ()

-- | BracketStyle controlling how closing bracket is rendered.
data BracketStyle

-- | Normal
N :: BracketStyle

-- | Shifted one level
S :: BracketStyle

-- | Set indentation level for the inner computation equal to current
--   column. This makes sure that the entire inner block is uniformly
--   "shifted" to the right.
sitcc :: R () -> R ()

-- | Surround given entity by backticks.
backticks :: R () -> R ()

-- | Surround given entity by banana brackets (i.e., from arrow notation.)
banana :: R () -> R ()

-- | Surround given entity by curly braces { and }.
braces :: BracketStyle -> R () -> R ()

-- | Surround given entity by square brackets [ and ].
brackets :: BracketStyle -> R () -> R ()

-- | Surround given entity by parentheses ( and ).
parens :: BracketStyle -> R () -> R ()

-- | Surround given entity by (#  and  #).
parensHash :: BracketStyle -> R () -> R ()

-- | Braces as used for pragmas: {-# and #-}.
pragmaBraces :: R () -> R ()

-- | Surround the body with a pragma name and pragmaBraces.
pragma :: Text -> R () -> R ()

-- | Print ,.
comma :: R ()

-- | Delimiting combination with comma. To be used with sep.
commaDel :: R ()

-- | Print =. Do not use txt "=".
equals :: R ()

-- | An auxiliary marker for keeping track of last output element.
data SpanMark

-- | Haddock comment
HaddockSpan :: HaddockStyle -> RealSrcSpan -> SpanMark

-- | Non-haddock comment
CommentSpan :: RealSrcSpan -> SpanMark

-- | A statement in a do-block and such span
StatementSpan :: RealSrcSpan -> SpanMark

-- | Project RealSrcSpan from SpanMark.
spanMarkSpan :: SpanMark -> RealSrcSpan

-- | Haddock string style.
data HaddockStyle

-- | 
--   -- |
--   
Pipe :: HaddockStyle

-- | 
--   -- ^
--   
Caret :: HaddockStyle

-- | 
--   -- *
--   
Asterisk :: Int -> HaddockStyle

-- | 
--   -- $
--   
Named :: String -> HaddockStyle

-- | Set span of last output comment.
setSpanMark :: SpanMark -> R ()

-- | Get span of last output comment.
getSpanMark :: R (Maybe SpanMark)
instance GHC.Show.Show Ormolu.Printer.Combinators.BracketStyle
instance GHC.Classes.Eq Ormolu.Printer.Combinators.BracketStyle

-- | Pretty-printing of language pragmas.
module Ormolu.Printer.Meat.Pragma

-- | Print a collection of Pragmas with their associated comments.
p_pragmas :: [([RealLocated Comment], Pragma)] -> R ()
instance GHC.Classes.Ord Ormolu.Printer.Meat.Pragma.PragmaTy
instance GHC.Classes.Eq Ormolu.Printer.Meat.Pragma.PragmaTy
instance GHC.Classes.Ord Ormolu.Printer.Meat.Pragma.LanguagePragmaClass
instance GHC.Classes.Eq Ormolu.Printer.Meat.Pragma.LanguagePragmaClass

-- | Rendering of commonly useful bits.
module Ormolu.Printer.Meat.Common

-- | Data and type family style.
data FamilyStyle

-- | Declarations in type classes
Associated :: FamilyStyle

-- | Top-level declarations
Free :: FamilyStyle
p_hsmodName :: ModuleName -> R ()
p_ieWrappedName :: IEWrappedName RdrName -> R ()

-- | Render a Located RdrName.
p_rdrName :: Located RdrName -> R ()

-- | Whether given name should not have parentheses around it. This is used
--   to detect e.g. tuples for which annotations will indicate parentheses,
--   but the parentheses are already part of the symbol, so no extra layer
--   of parentheses should be added. It also detects the [] literal.
doesNotNeedExtraParens :: RdrName -> Bool
p_qualName :: ModuleName -> OccName -> R ()

-- | A helper for formatting infix constructions in lhs of definitions.
p_infixDefHelper :: Bool -> Bool -> R () -> [R ()] -> R ()

-- | Print a Haddock.
p_hsDocString :: HaddockStyle -> Bool -> LHsDocString -> R ()

-- | Print anchor of named doc section.
p_hsDocName :: String -> R ()

-- | Rendering of types.
module Ormolu.Printer.Meat.Type
p_hsType :: HsType GhcPs -> R ()
p_hsTypePostDoc :: HsType GhcPs -> R ()

-- | Return True if at least one argument in HsType has a doc
--   string attached to it.
hasDocStrings :: HsType GhcPs -> Bool
p_hsContext :: HsContext GhcPs -> R ()
p_hsTyVarBndr :: HsTyVarBndr GhcPs -> R ()

-- | Render several forall-ed variables.
p_forallBndrs :: Data a => ForallVisFlag -> (a -> R ()) -> [Located a] -> R ()
p_conDeclFields :: [LConDeclField GhcPs] -> R ()
tyVarsToTypes :: LHsQTyVars GhcPs -> [LHsType GhcPs]

module Ormolu.Printer.Meat.Declaration.Default
p_defaultDecl :: DefaultDecl GhcPs -> R ()

-- | Rendering of import and export lists.
module Ormolu.Printer.Meat.ImportExport
p_hsmodExports :: [LIE GhcPs] -> R ()
p_hsmodImport :: Bool -> ImportDecl GhcPs -> R ()

module Ormolu.Printer.Meat.Declaration.Warning
p_warnDecls :: WarnDecls GhcPs -> R ()
p_moduleWarning :: WarningTxt -> R ()

-- | Rendering of data/type families.
module Ormolu.Printer.Meat.Declaration.TypeFamily
p_famDecl :: FamilyStyle -> FamilyDecl GhcPs -> R ()
p_tyFamInstEqn :: TyFamInstEqn GhcPs -> R ()

-- | Rendering of type synonym declarations.
module Ormolu.Printer.Meat.Declaration.Type
p_synDecl :: Located RdrName -> LexicalFixity -> LHsQTyVars GhcPs -> LHsType GhcPs -> R ()

-- | Type signature declarations.
module Ormolu.Printer.Meat.Declaration.Signature
p_sigDecl :: Sig GhcPs -> R ()
p_typeAscription :: LHsSigWcType GhcPs -> R ()
p_activation :: Activation -> R ()
p_standaloneKindSig :: StandaloneKindSig GhcPs -> R ()

-- | Rendering of Role annotation declarations.
module Ormolu.Printer.Meat.Declaration.RoleAnnotation
p_roleAnnot :: RoleAnnotDecl GhcPs -> R ()

module Ormolu.Printer.Meat.Declaration.Foreign
p_foreignDecl :: ForeignDecl GhcPs -> R ()

-- | Renedring of data type declarations.
module Ormolu.Printer.Meat.Declaration.Data
p_dataDecl :: FamilyStyle -> Located RdrName -> [LHsType GhcPs] -> LexicalFixity -> HsDataDefn GhcPs -> R ()

module Ormolu.Printer.Meat.Declaration.Value
p_valDecl :: HsBindLR GhcPs GhcPs -> R ()
p_pat :: Pat GhcPs -> R ()
p_hsExpr :: HsExpr GhcPs -> R ()
p_hsSplice :: HsSplice GhcPs -> R ()
p_stringLit :: String -> R ()
instance GHC.Show.Show Ormolu.Printer.Meat.Declaration.Value.Placement
instance GHC.Classes.Eq Ormolu.Printer.Meat.Declaration.Value.Placement

module Ormolu.Printer.Meat.Declaration.Splice
p_spliceDecl :: SpliceDecl GhcPs -> R ()

module Ormolu.Printer.Meat.Declaration.Rule
p_ruleDecls :: RuleDecls GhcPs -> R ()

module Ormolu.Printer.Meat.Declaration.Annotation
p_annDecl :: AnnDecl GhcPs -> R ()

-- | Type class, type family, and data family instance declarations.
module Ormolu.Printer.Meat.Declaration.Instance
p_clsInstDecl :: ClsInstDecl GhcPs -> R ()
p_tyFamInstDecl :: FamilyStyle -> TyFamInstDecl GhcPs -> R ()
p_dataFamInstDecl :: FamilyStyle -> DataFamInstDecl GhcPs -> R ()
p_standaloneDerivDecl :: DerivDecl GhcPs -> R ()

-- | Rendering of type class declarations.
module Ormolu.Printer.Meat.Declaration.Class
p_classDecl :: LHsContext GhcPs -> Located RdrName -> LHsQTyVars GhcPs -> LexicalFixity -> [Located (FunDep (Located RdrName))] -> [LSig GhcPs] -> LHsBinds GhcPs -> [LFamilyDecl GhcPs] -> [LTyFamDefltDecl GhcPs] -> [LDocDecl] -> R ()

-- | Rendering of declarations.
module Ormolu.Printer.Meat.Declaration
p_hsDecls :: FamilyStyle -> [LHsDecl GhcPs] -> R ()

-- | Like p_hsDecls but respects user choices regarding grouping. If
--   the user omits newlines between declarations, we also omit them in
--   most cases, except when said declarations have associated Haddocks.
--   
--   Does some normalization (compress subsequent newlines into a single
--   one)
p_hsDeclsRespectGrouping :: FamilyStyle -> [LHsDecl GhcPs] -> R ()
instance GHC.Show.Show Ormolu.Printer.Meat.Declaration.UserGrouping
instance GHC.Classes.Eq Ormolu.Printer.Meat.Declaration.UserGrouping

-- | A type for result of parsing.
module Ormolu.Parser.Result

-- | A collection of data that represents a parsed module in Ormolu.
data ParseResult
ParseResult :: HsModule GhcPs -> Anns -> Maybe (RealLocated Comment) -> [Shebang] -> [([RealLocated Comment], Pragma)] -> CommentStream -> Bool -> Bool -> Text -> Text -> Int -> ParseResult

-- | ParsedSource from GHC
[prParsedSource] :: ParseResult -> HsModule GhcPs

-- | Ormolu-specfic representation of annotations
[prAnns] :: ParseResult -> Anns

-- | Stack header
[prStackHeader] :: ParseResult -> Maybe (RealLocated Comment)

-- | Shebangs found in the input
[prShebangs] :: ParseResult -> [Shebang]

-- | Pragmas and the associated comments
[prPragmas] :: ParseResult -> [([RealLocated Comment], Pragma)]

-- | Comment stream
[prCommentStream] :: ParseResult -> CommentStream

-- | Whether or not record dot syntax is enabled
[prUseRecordDot] :: ParseResult -> Bool

-- | Whether or not ImportQualifiedPost is enabled
[prImportQualifiedPost] :: ParseResult -> Bool

-- | Literal prefix
[prLiteralPrefix] :: ParseResult -> Text

-- | Literal suffix
[prLiteralSuffix] :: ParseResult -> Text

-- | Indentation level, can be non-zero in case of region formatting
[prIndent] :: ParseResult -> Int

-- | Pretty-print a ParseResult.
prettyPrintParseResult :: ParseResult -> String

-- | Manipulations on import lists.
module Ormolu.Imports

-- | Sort and normalize imports.
normalizeImports :: [LImportDecl GhcPs] -> [LImportDecl GhcPs]
instance GHC.Classes.Eq Ormolu.Imports.IEWrappedNameOrd
instance GHC.Classes.Ord Ormolu.Imports.ImportId
instance GHC.Classes.Eq Ormolu.Imports.ImportId
instance GHC.Classes.Ord Ormolu.Imports.IEWrappedNameOrd

-- | Rendering of modules.
module Ormolu.Printer.Meat.Module

-- | Render a module.
p_hsModule :: Maybe (RealLocated Comment) -> [Shebang] -> [([RealLocated Comment], Pragma)] -> Bool -> HsModule GhcPs -> R ()

-- | Pretty-printer for Haskell AST.
module Ormolu.Printer

-- | Render a module.
printModule :: ParseResult -> Text

-- | OrmoluException type and surrounding definitions.
module Ormolu.Exception

-- | Ormolu exception representing all cases when Ormolu can fail.
data OrmoluException

-- | Parsing of original source code failed
OrmoluParsingFailed :: SrcSpan -> String -> OrmoluException

-- | Parsing of formatted source code failed
OrmoluOutputParsingFailed :: SrcSpan -> String -> OrmoluException

-- | Original and resulting ASTs differ
OrmoluASTDiffers :: FilePath -> [SrcSpan] -> OrmoluException

-- | Formatted source code is not idempotent
OrmoluNonIdempotentOutput :: RealSrcLoc -> Text -> Text -> OrmoluException

-- | Some GHC options were not recognized
OrmoluUnrecognizedOpts :: NonEmpty String -> OrmoluException

-- | Inside this wrapper OrmoluException will be caught and
--   displayed nicely using displayException.
withPrettyOrmoluExceptions :: IO a -> IO a
instance GHC.Show.Show Ormolu.Exception.OrmoluException
instance GHC.Classes.Eq Ormolu.Exception.OrmoluException
instance GHC.Exception.Type.Exception Ormolu.Exception.OrmoluException

-- | Parser for Haskell source code.
module Ormolu.Parser

-- | Parse a complete module from string.
parseModule :: MonadIO m => Config RegionDeltas -> FilePath -> String -> m ([Warn], Either (SrcSpan, String) ParseResult)

-- | Extensions that are not enabled automatically and should be activated
--   by user.
manualExts :: [Extension]
instance GHC.Classes.Eq Ormolu.Parser.SeverityOrd
instance GHC.Classes.Ord Ormolu.Parser.SeverityOrd

-- | Diffing GHC ASTs modulo span positions.
module Ormolu.Diff

-- | Result of comparing two ParseResults.
data Diff

-- | Two parse results are the same
Same :: Diff

-- | Two parse results differ
Different :: [SrcSpan] -> Diff

-- | Return Diff of two ParseResults.
diffParseResult :: ParseResult -> ParseResult -> Diff

-- | Diff two texts and return the location they start to differ, alongside
--   with excerpts around that location.
diffText :: Text -> Text -> FilePath -> Maybe (RealSrcLoc, Text, Text)
instance GHC.Base.Semigroup Ormolu.Diff.Diff
instance GHC.Base.Monoid Ormolu.Diff.Diff

-- | A formatter for Haskell source code.
module Ormolu

-- | Format a String, return formatted version as Text.
--   
--   The function
--   
--   
--   
- Takes String because that's what GHC parser accepts.
--   
- Needs IO because some functions from GHC that are necessary
--   to setup parsing context require IO. There should be no visible
--   side-effects though.
--   
- Takes file name just to use it in parse error messages.
--   
- Throws OrmoluException.
--   
ormolu :: MonadIO m => Config RegionIndices -> FilePath -> String -> m Text

-- | Load a file and format it. The file stays intact and the rendered
--   version is returned as Text.
--   
--   
--   ormoluFile cfg path =
--     liftIO (readFile path) >>= ormolu cfg path
--   
ormoluFile :: MonadIO m => Config RegionIndices -> FilePath -> m Text

-- | Read input from stdin and format it.
--   
--   
--   ormoluStdin cfg =
--     liftIO (hGetContents stdin) >>= ormolu cfg "<stdin>"
--   
ormoluStdin :: MonadIO m => Config RegionIndices -> m Text

-- | Ormolu configuration.
data Config region
Config :: ![DynOption] -> !Bool -> !Bool -> !Bool -> !region -> Config region

-- | Dynamic options to pass to GHC parser
[cfgDynOptions] :: Config region -> ![DynOption]

-- | Do formatting faster but without automatic detection of defects
[cfgUnsafe] :: Config region -> !Bool

-- | Output information useful for debugging
[cfgDebug] :: Config region -> !Bool

-- | Checks if re-formatting the result is idempotent
[cfgCheckIdempotence] :: Config region -> !Bool

-- | Region selection
[cfgRegion] :: Config region -> !region

-- | Region selection as the combination of start and end line numbers.
data RegionIndices
RegionIndices :: !Maybe Int -> !Maybe Int -> RegionIndices

-- | Start line of the region to format
[regionStartLine] :: RegionIndices -> !Maybe Int

-- | End line of the region to format
[regionEndLine] :: RegionIndices -> !Maybe Int

-- | Default Config RegionIndices.
defaultConfig :: Config RegionIndices

-- | A wrapper for dynamic options.
newtype DynOption
DynOption :: String -> DynOption
[unDynOption] :: DynOption -> String

-- | Ormolu exception representing all cases when Ormolu can fail.
data OrmoluException

-- | Parsing of original source code failed
OrmoluParsingFailed :: SrcSpan -> String -> OrmoluException

-- | Parsing of formatted source code failed
OrmoluOutputParsingFailed :: SrcSpan -> String -> OrmoluException

-- | Original and resulting ASTs differ
OrmoluASTDiffers :: FilePath -> [SrcSpan] -> OrmoluException

-- | Formatted source code is not idempotent
OrmoluNonIdempotentOutput :: RealSrcLoc -> Text -> Text -> OrmoluException

-- | Some GHC options were not recognized
OrmoluUnrecognizedOpts :: NonEmpty String -> OrmoluException

-- | Inside this wrapper OrmoluException will be caught and
--   displayed nicely using displayException.
withPrettyOrmoluExceptions :: IO a -> IO a
