-- 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.0.3.1


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

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

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

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

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

-- | Do not fail if CPP pragma is present (still doesn't handle CPP but
--   useful for formatting of files that enable the extension without
--   actually containing CPP macros)
[cfgTolerateCpp] :: Config -> !Bool

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

-- | Default <a>Config</a>.
defaultConfig :: Config

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

-- | Convert <a>DynOption</a> to <tt><a>Located</a> <a>String</a></tt>.
dynOptionToLocatedStr :: DynOption -> Located String
instance GHC.Show.Show Ormolu.Config.Config
instance GHC.Classes.Eq Ormolu.Config.Config
instance GHC.Show.Show Ormolu.Config.DynOption
instance GHC.Classes.Ord Ormolu.Config.DynOption
instance GHC.Classes.Eq Ormolu.Config.DynOption


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

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

-- | Empty <a>Anns</a>.
emptyAnns :: Anns

-- | Create <a>Anns</a> from <a>PState</a>.
mkAnns :: PState -> Anns

-- | Lookup <a>AnnKeywordId</a>s corresponding to a given <a>SrcSpan</a>.
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 <a>Nothing</a>
--   otherwise.
parsePragma :: String -> Maybe Pragma
instance GHC.Classes.Eq Ormolu.Parser.Pragma.Pragma
instance GHC.Show.Show Ormolu.Parser.Pragma.Pragma


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

-- | A stream of <a>RealSrcSpan</a>s 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 <a>SpanStream</a> 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


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

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

-- | Return <a>True</a> if given element of AST is module.
isModule :: Data a => a -> Bool

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

-- | Pretty-print an <a>Outputable</a> 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]
typeArgToType :: LHsTypeArg p -> LHsType p
unSrcSpan :: SrcSpan -> Maybe RealSrcSpan

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


-- | 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: <tt>ty</tt> is the type of sub-expressions, while
--   <tt>op</tt> 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 <a>SrcSpan</a>s of all elements in this <a>OpTree</a>.
opTreeLoc :: OpTree (Located a) b -> SrcSpan

-- | Re-associate an <a>OpTree</a> taking into account automagically
--   inferred relative precedence of operators. Users are expected to first
--   construct an initial <a>OpTree</a>, then re-associate it using this
--   function before printing.
reassociateOpTree :: (op -> Maybe RdrName) -> OpTree (Located ty) (Located op) -> OpTree (Located ty) (Located op)


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

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

-- | A wrapper for a single comment. The <a>NonEmpty</a> list inside
--   contains lines of multiline comment <tt>{- … -}</tt> or just single
--   item/line otherwise.
newtype Comment
Comment :: NonEmpty String -> Comment

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

-- | Return <a>True</a> if given <a>String</a> is a shebang.
isShebang :: String -> Bool

-- | Test whether a <a>Comment</a> looks like a Haddock following a
--   definition, i.e. something starting with <tt>-- ^</tt>.
isPrevHaddock :: Comment -> Bool

-- | Is this comment multiline-style?
isMultilineComment :: Comment -> Bool

-- | Pretty-print a <a>CommentStream</a>.
showCommentStream :: CommentStream -> String
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 <a>Ormolu.Printer.Combinators</a> instead, these
--   functions are the low-level building blocks and should not be used on
--   their own. The <a>R</a> monad is re-exported from
--   <a>Ormolu.Printer.Combinators</a> as well.
module Ormolu.Printer.Internal

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

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

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

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

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

-- | Check if the current line is “dirty”, that is, there is something on
--   it that can have comments attached to it.
isLineDirty :: R Bool

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

-- | Increase indentation level by one indentation step for the inner
--   computation. <a>inci</a> should be used when a part of code must be
--   more indented relative to the parts outside of <a>inci</a> 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. Only works (and makes sense) when enclosing
--   layout is multi-line.
sitcc :: R () -> R ()

-- | <a>Layout</a> options.
data Layout

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

-- | Use multiple lines
MultiLine :: Layout

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

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

-- | Get current <a>Layout</a>.
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 <a>True</a> 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
--   <a>SrcSpan</a>.
trimSpanStream :: RealSrcSpan -> R ()

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

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

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

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

-- | Haddock string style.
data HaddockStyle

-- | <pre>
--   -- |
--   </pre>
Pipe :: HaddockStyle

-- | <pre>
--   -- ^
--   </pre>
Caret :: HaddockStyle

-- | <pre>
--   -- *
--   </pre>
Asterisk :: Int -> HaddockStyle

-- | <pre>
--   -- $
--   </pre>
Named :: String -> HaddockStyle

-- | Set span of last output comment.
setLastCommentSpan :: Maybe HaddockStyle -> RealSrcSpan -> R ()

-- | Get span of last output comment.
getLastCommentSpan :: R (Maybe (Maybe HaddockStyle, RealSrcSpan))

-- | For a given span return <a>AnnKeywordId</a>s 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.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
--   <a>Ormolu.Printer.Combinators</a> unless you know what you are doing.
module Ormolu.Printer.Comments

-- | Output all preceding comments for an element at given location.
spitPrecedingComments :: Data a => RealLocated a -> R ()

-- | Output all comments following an element at given location.
spitFollowingComments :: Data a => RealLocated a -> R ()

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

-- | If there is a stack header in the comment stream, print it.
spitStackHeader :: 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 <a>R</a> monad hosts combinators that allow us to describe how to
--   render AST.
data R a

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

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

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

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

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

-- | This primitive <i>does not</i> 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 <a>newline</a> is used after some
--   non-<a>newline</a> output it gets inserted immediately. Second use of
--   <a>newline</a> does not output anything but makes sure that the next
--   non-white space output will be prefixed by a newline. Using
--   <a>newline</a> more than twice in a row has no effect. Also, using
--   <a>newline</a> at the very beginning has no effect, this is to avoid
--   leading whitespace.
--   
--   Similarly to <a>space</a>, 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. <a>inci</a> should be used when a part of code must be
--   more indented relative to the parts outside of <a>inci</a> 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 ()

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

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

-- | A version of <a>located</a> that works on <a>Pat</a>.
--   
--   Starting from GHC 8.8, <tt><tt>LPat</tt> == <a>Pat</a></tt>. Located
--   <a>Pat</a>s are always constructed with the <a>XPat</a> constructor,
--   containing a <tt><a>Located</a> <a>Pat</a></tt>.
--   
--   Most of the time, we can just use <tt>p_pat</tt> directly, because it
--   handles located <a>Pat</a>s. However, sometimes we want to use the
--   location to render something other than the given <a>Pat</a>.
--   
--   If given <a>Pat</a> does not contain a location, we error out.
--   
--   This should become unnecessary if
--   <a>https://gitlab.haskell.org/ghc/ghc/issues/17330</a> is ever fixed.
locatedPat :: (Data (Pat pass), XXPat pass ~ Located (Pat pass)) => Pat pass -> (Pat pass -> R ()) -> R ()

-- | Set layout according to combination of given <a>SrcSpan</a>s 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
--   <a>Located</a> 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 ()

-- | <a>Layout</a> options.
data Layout

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

-- | Use multiple lines
MultiLine :: Layout

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

-- | Get current <a>Layout</a>.
getLayout :: R Layout

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

-- | Similar to <a>breakpoint</a> but outputs nothing in case of
--   single-line layout.
--   
--   <pre>
--   breakpoint' = vlayout (return ()) newline
--   </pre>
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
--   <a>useBraces</a> and <a>dontUseBraces</a> combinators.
--   
--   <pre>
--   useBraces $ sepSemi txt ["foo", "bar"]
--     == vlayout (txt "{ foo; bar }") (txt "foo\nbar")
--   </pre>
--   
--   <pre>
--   dontUseBraces $ sepSemi txt ["foo", "bar"]
--     == vlayout (txt "foo; bar") (txt "foo\nbar")
--   </pre>
sepSemi :: (a -> R ()) -> [a] -> R ()

-- | Return <a>True</a> 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 ()

-- | <a>BracketStyle</a> 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. Only works (and makes sense) when enclosing
--   layout is multi-line.
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 <tt>{</tt> and <tt>}</tt>.
braces :: BracketStyle -> R () -> R ()

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

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

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

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

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

-- | Print <tt>,</tt>.
comma :: R ()

-- | Haddock string style.
data HaddockStyle

-- | <pre>
--   -- |
--   </pre>
Pipe :: HaddockStyle

-- | <pre>
--   -- ^
--   </pre>
Caret :: HaddockStyle

-- | <pre>
--   -- *
--   </pre>
Asterisk :: Int -> HaddockStyle

-- | <pre>
--   -- $
--   </pre>
Named :: String -> HaddockStyle

-- | Set span of last output comment.
setLastCommentSpan :: Maybe HaddockStyle -> RealSrcSpan -> R ()

-- | Get span of last output comment.
getLastCommentSpan :: R (Maybe (Maybe HaddockStyle, RealSrcSpan))


-- | Pretty-printing of language pragmas.
module Ormolu.Printer.Meat.Pragma
p_pragmas :: [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 <tt><a>Located</a> <a>RdrName</a></tt>.
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 -> (R () -> R ()) -> 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 ()

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

-- | Render several <tt>forall</tt>-ed variables.
p_forallBndrs :: Data a => (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 :: 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 ()


-- | 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.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] -> [LTyFamDefltEqn GhcPs] -> [LDocDecl] -> R ()


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

-- | Like <a>p_hsDecls</a> 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 :: ParsedSource -> Anns -> CommentStream -> [Pragma] -> [Located String] -> Bool -> ParseResult

-- | <a>ParsedSource</a> from GHC
[prParsedSource] :: ParseResult -> ParsedSource

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

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

-- | Extensions enabled in that module
[prExtensions] :: ParseResult -> [Pragma]

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

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

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


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

-- | Sort imports by module name. This also sorts explicit import lists for
--   each declaration.
sortImports :: [LImportDecl GhcPs] -> [LImportDecl GhcPs]


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

-- | Render a module.
p_hsModule :: [Located String] -> [Pragma] -> ParsedSource -> R ()


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

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


-- | <a>OrmoluException</a> type and surrounding definitions.
module Ormolu.Exception

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

-- | Ormolu does not work with source files that use CPP
OrmoluCppEnabled :: FilePath -> 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 <a>OrmoluException</a> will be caught and
--   displayed nicely using <a>displayException</a>.
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 -> FilePath -> String -> m ([Warn], Either (SrcSpan, String) ParseResult)

-- | Extensions that are not enabled automatically and should be activated
--   by user.
manualExts :: [Extension]


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

-- | Result of comparing two <a>ParseResult</a>s.
data Diff

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

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

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

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

-- | Read input from stdin and format it.
--   
--   <pre>
--   ormoluStdin cfg =
--     liftIO (hGetContents stdin) &gt;&gt;= ormolu cfg "&lt;stdin&gt;"
--   </pre>
ormoluStdin :: MonadIO m => Config -> m Text

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

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

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

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

-- | Do not fail if CPP pragma is present (still doesn't handle CPP but
--   useful for formatting of files that enable the extension without
--   actually containing CPP macros)
[cfgTolerateCpp] :: Config -> !Bool

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

-- | Default <a>Config</a>.
defaultConfig :: Config

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

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

-- | Ormolu does not work with source files that use CPP
OrmoluCppEnabled :: FilePath -> 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 <a>OrmoluException</a> will be caught and
--   displayed nicely using <a>displayException</a>.
withPrettyOrmoluExceptions :: IO a -> IO a
