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

module Ormolu.Fixity.Internal

-- | An operator name.
data OpName
pattern OpName :: Text -> OpName

-- | Convert an <a>OpName</a> to <a>Text</a>.
unOpName :: OpName -> Text

-- | Convert an 'OccName to an <a>OpName</a>.
occOpName :: OccName -> OpName

-- | Fixity direction.
data FixityDirection
InfixL :: FixityDirection
InfixR :: FixityDirection
InfixN :: FixityDirection

-- | Fixity information about an infix operator that takes the uncertainty
--   that can arise from conflicting definitions into account.
data FixityInfo
FixityInfo :: Maybe FixityDirection -> Int -> Int -> FixityInfo

-- | Fixity direction if it is known
[fiDirection] :: FixityInfo -> Maybe FixityDirection

-- | Minimum precedence level found in the (maybe conflicting) definitions
--   for the operator (inclusive)
[fiMinPrecedence] :: FixityInfo -> Int

-- | Maximum precedence level found in the (maybe conflicting) definitions
--   for the operator (inclusive)
[fiMaxPrecedence] :: FixityInfo -> Int

-- | The lowest level of information we can have about an operator.
defaultFixityInfo :: FixityInfo

-- | Fixity info of the built-in colon data constructor.
colonFixityInfo :: FixityInfo

-- | The map of operators declared by each package and the popularity of
--   each package, if available.
data HackageInfo
HackageInfo :: Map PackageName FixityMap -> Map PackageName Int -> HackageInfo

-- | Map from the operator name to its <a>FixityInfo</a>.
type FixityMap = Map OpName FixityInfo

-- | A variant of <a>FixityMap</a>, represented as a lazy union of several
--   <a>FixityMap</a>s.
newtype LazyFixityMap
LazyFixityMap :: [FixityMap] -> LazyFixityMap

-- | Lookup a <a>FixityInfo</a> of an operator. This might have drastically
--   different performance depending on whether this is an "unusual"
--   operator.
lookupFixity :: OpName -> LazyFixityMap -> Maybe FixityInfo
instance Data.Binary.Class.Binary Ormolu.Fixity.Internal.FixityDirection
instance GHC.Generics.Generic Ormolu.Fixity.Internal.FixityDirection
instance GHC.Show.Show Ormolu.Fixity.Internal.FixityDirection
instance GHC.Classes.Ord Ormolu.Fixity.Internal.FixityDirection
instance GHC.Classes.Eq Ormolu.Fixity.Internal.FixityDirection
instance Data.Binary.Class.Binary Ormolu.Fixity.Internal.FixityInfo
instance GHC.Generics.Generic Ormolu.Fixity.Internal.FixityInfo
instance GHC.Show.Show Ormolu.Fixity.Internal.FixityInfo
instance GHC.Classes.Ord Ormolu.Fixity.Internal.FixityInfo
instance GHC.Classes.Eq Ormolu.Fixity.Internal.FixityInfo
instance Data.Binary.Class.Binary Ormolu.Fixity.Internal.OpName
instance GHC.Classes.Ord Ormolu.Fixity.Internal.OpName
instance GHC.Classes.Eq Ormolu.Fixity.Internal.OpName
instance GHC.Show.Show Ormolu.Fixity.Internal.LazyFixityMap
instance Data.Binary.Class.Binary Ormolu.Fixity.Internal.HackageInfo
instance GHC.Generics.Generic Ormolu.Fixity.Internal.HackageInfo
instance GHC.Show.Show Ormolu.Fixity.Internal.OpName
instance Data.String.IsString Ormolu.Fixity.Internal.OpName
instance GHC.Base.Semigroup Ormolu.Fixity.Internal.FixityInfo


-- | Definitions for fixity analysis.
module Ormolu.Fixity

-- | An operator name.
data OpName
pattern OpName :: Text -> OpName

-- | Convert an <a>OpName</a> to <a>Text</a>.
unOpName :: OpName -> Text

-- | Convert an 'OccName to an <a>OpName</a>.
occOpName :: OccName -> OpName

-- | Fixity direction.
data FixityDirection
InfixL :: FixityDirection
InfixR :: FixityDirection
InfixN :: FixityDirection

-- | Fixity information about an infix operator that takes the uncertainty
--   that can arise from conflicting definitions into account.
data FixityInfo
FixityInfo :: Maybe FixityDirection -> Int -> Int -> FixityInfo

-- | Fixity direction if it is known
[fiDirection] :: FixityInfo -> Maybe FixityDirection

-- | Minimum precedence level found in the (maybe conflicting) definitions
--   for the operator (inclusive)
[fiMinPrecedence] :: FixityInfo -> Int

-- | Maximum precedence level found in the (maybe conflicting) definitions
--   for the operator (inclusive)
[fiMaxPrecedence] :: FixityInfo -> Int

-- | Map from the operator name to its <a>FixityInfo</a>.
type FixityMap = Map OpName FixityInfo

-- | A variant of <a>FixityMap</a>, represented as a lazy union of several
--   <a>FixityMap</a>s.
data LazyFixityMap

-- | Lookup a <a>FixityInfo</a> of an operator. This might have drastically
--   different performance depending on whether this is an "unusual"
--   operator.
lookupFixity :: OpName -> LazyFixityMap -> Maybe FixityInfo

-- | The map of operators declared by each package and the popularity of
--   each package, if available.
data HackageInfo
HackageInfo :: Map PackageName FixityMap -> Map PackageName Int -> HackageInfo

-- | The default value for the popularity ratio threshold, after which a
--   very popular definition from packageToOps will completely rule out
--   conflicting definitions instead of being merged with them.
defaultStrategyThreshold :: Float

-- | The lowest level of information we can have about an operator.
defaultFixityInfo :: FixityInfo

-- | Build a fixity map using the given popularity threshold and a list of
--   cabal dependencies. Dependencies from the list have higher priority
--   than other packages.
buildFixityMap :: Float -> Set PackageName -> LazyFixityMap

-- | Build a fixity map using the given popularity threshold and a list of
--   cabal dependencies. Dependencies from the list have higher priority
--   than other packages. This specific version of the function allows the
--   user to specify the package databases used to build the final fixity
--   map.
buildFixityMap' :: Map PackageName FixityMap -> Map PackageName Int -> Set PackageName -> Float -> Set PackageName -> LazyFixityMap

-- | List of packages shipped with GHC, for which the download count from
--   Hackage does not reflect their high popularity. See
--   <a>https://github.com/tweag/ormolu/pull/830#issuecomment-986609572</a>.
--   "base" is not is this list, because it is already whitelisted by
--   buildFixityMap'.
bootPackages :: Set PackageName
packageToOps :: Map PackageName FixityMap
packageToPopularity :: Map PackageName Int


-- | Parser for fixity maps.
module Ormolu.Fixity.Parser

-- | Parse textual representation of a <a>FixityMap</a>.
parseFixityMap :: FilePath -> Text -> Either (ParseErrorBundle Text Void) FixityMap

-- | Parse a single self-contained fixity declaration.
parseFixityDeclaration :: Text -> Either (ParseErrorBundle Text Void) [(OpName, FixityInfo)]

-- | Parse a single fixity declaration, such as
--   
--   <pre>
--   infixr 4 +++, &gt;&gt;&gt;
--   </pre>
pFixity :: Parser [(OpName, FixityInfo)]

-- | See
--   <a>https://www.haskell.org/onlinereport/haskell2010/haskellch2.html</a>
pOperator :: Parser OpName


-- | Printer for fixity maps.
module Ormolu.Fixity.Printer

-- | Print out a textual representation of a <a>FixityMap</a>.
printFixityMap :: FixityMap -> Text


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


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

-- | Return an <a>IntSet</a> containing all lines which are affected by
--   CPP.
cppLines :: Text -> IntSet
instance GHC.Show.Show Ormolu.Processing.Cpp.State
instance GHC.Classes.Eq Ormolu.Processing.Cpp.State


-- | 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 <a>RelativePos</a>es 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 <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]

-- | Increment line number in a <a>SrcSpan</a>.
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 <a>True</a> if one span ends on the same line the second one
--   starts.
onTheSameLine :: SrcSpan -> SrcSpan -> Bool
class HasSrcSpan l
loc' :: HasSrcSpan l => l -> SrcSpan
getLoc' :: HasSrcSpan l => GenLocated l a -> SrcSpan

-- | Check whether the given <a>AnnKeywordId</a> or its Unicode variant is
--   in an <a>AddEpAnn</a>, and return the <a>EpaLocation</a> if so.
matchAddEpAnn :: AnnKeywordId -> AddEpAnn -> Maybe EpaLocation

-- | Convert <a>Text</a> to a <a>StringBuffer</a> by making a copy.
textToStringBuffer :: Text -> StringBuffer
instance GHC.Show.Show Ormolu.Utils.RelativePos
instance GHC.Classes.Eq Ormolu.Utils.RelativePos
instance Ormolu.Utils.HasSrcSpan GHC.Types.SrcLoc.SrcSpan
instance Ormolu.Utils.HasSrcSpan (GHC.Parser.Annotation.SrcSpanAnn' ann)


-- | An abstraction for colorful output in terminal.
module Ormolu.Terminal

-- | Terminal monad.
data Term a

-- | Whether to use colors and other features of ANSI terminals.
data ColorMode
Never :: ColorMode
Always :: ColorMode
Auto :: ColorMode

-- | Run <a>Term</a> monad.
runTerm :: Term a -> ColorMode -> Handle -> IO a

-- | Make the inner computation output bold text.
bold :: Term a -> Term a

-- | Make the inner computation output cyan text.
cyan :: Term a -> Term a

-- | Make the inner computation output green text.
green :: Term a -> Term a

-- | Make the inner computation output red text.
red :: Term a -> Term a

-- | Output <a>Text</a>.
put :: Text -> Term ()

-- | Output <a>String</a>.
putS :: String -> Term ()

-- | Output a <a>SrcSpan</a>.
putSrcSpan :: SrcSpan -> Term ()

-- | Output a <a>RealSrcSpan</a>.
putRealSrcSpan :: RealSrcSpan -> Term ()

-- | Output a newline.
newline :: Term ()
instance GHC.Base.Monad Ormolu.Terminal.Term
instance GHC.Base.Applicative Ormolu.Terminal.Term
instance GHC.Base.Functor Ormolu.Terminal.Term
instance GHC.Show.Show Ormolu.Terminal.ColorMode
instance GHC.Classes.Eq Ormolu.Terminal.ColorMode


-- | This module allows us to diff two <a>Text</a> values.
module Ormolu.Diff.Text

-- | Result of diffing two <a>Text</a>s.
data TextDiff

-- | Diff two texts and produce a <a>TextDiff</a>.
diffText :: Text -> Text -> FilePath -> Maybe TextDiff

-- | Select certain spans in the diff (line numbers are interpreted as
--   belonging to the “before” state). Only selected spans will be printed.
selectSpans :: [RealSrcSpan] -> TextDiff -> TextDiff

-- | Print the given <a>TextDiff</a> as a <a>Term</a> action. This function
--   tries to mimic the style of <tt>git diff</tt>.
printTextDiff :: TextDiff -> Term ()
instance GHC.Show.Show Ormolu.Diff.Text.TextDiff
instance GHC.Classes.Eq Ormolu.Diff.Text.TextDiff
instance GHC.Show.Show Ormolu.Diff.Text.Hunk


-- | <a>OrmoluException</a> 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 :: TextDiff -> [RealSrcSpan] -> OrmoluException

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

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

-- | Cabal file parsing failed
OrmoluCabalFileParsingFailed :: FilePath -> OrmoluException

-- | Missing input file path when using stdin input and accounting for
--   .cabal files
OrmoluMissingStdinInputFile :: OrmoluException

-- | A parse error in a fixity overrides file
OrmoluFixityOverridesParseError :: ParseErrorBundle Text Void -> OrmoluException

-- | Print an <a>OrmoluException</a>.
printOrmoluException :: OrmoluException -> Term ()

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


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

-- | Ormolu configuration.
data Config region
Config :: ![DynOption] -> FixityMap -> !Set PackageName -> !Bool -> !Bool -> !Bool -> !SourceType -> !ColorMode -> !region -> Config region

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

-- | Fixity overrides
[cfgFixityOverrides] :: Config region -> FixityMap

-- | Known dependencies, if any
[cfgDependencies] :: Config region -> !Set PackageName

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

-- | How to parse the input (regular haskell module or Backpack file)
[cfgSourceType] :: Config region -> !SourceType

-- | Whether to use colors and other features of ANSI terminals
[cfgColorMode] :: Config region -> !ColorMode

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

-- | Whether to use colors and other features of ANSI terminals.
data ColorMode
Never :: ColorMode
Always :: ColorMode
Auto :: ColorMode

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

-- | Type of sources that can be formatted by Ormolu.
data SourceType

-- | Consider the input as a regular Haskell module
ModuleSource :: SourceType

-- | Consider the input as a Backpack module signature
SignatureSource :: SourceType

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

-- | Convert <a>RegionIndices</a> into <a>RegionDeltas</a>.
regionIndicesToDeltas :: Int -> RegionIndices -> RegionDeltas

-- | 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.SourceType
instance GHC.Classes.Eq Ormolu.Config.SourceType
instance GHC.Show.Show Ormolu.Config.RegionIndices
instance GHC.Classes.Eq Ormolu.Config.RegionIndices
instance GHC.Show.Show Ormolu.Config.RegionDeltas
instance GHC.Classes.Eq Ormolu.Config.RegionDeltas
instance GHC.Show.Show Ormolu.Config.DynOption
instance GHC.Classes.Ord Ormolu.Config.DynOption
instance GHC.Classes.Eq Ormolu.Config.DynOption
instance GHC.Generics.Generic (Ormolu.Config.Config region)
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)


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

-- | Remove indentation from a given <a>Text</a>. Return the input with
--   indentation removed and the detected indentation level.
removeIndentation :: Text -> (Text, Int)

-- | Add indentation to a <a>Text</a>.
reindent :: Int -> Text -> Text

-- | All lines in the region specified by <a>RegionDeltas</a>.
linesInRegion :: RegionDeltas -> Text -> Text

-- | Convert a set of line indices into disjoint <tt>RegionDelta</tt>s
intSetToRegions :: Int -> IntSet -> [RegionDeltas]


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

-- | Preprocess the specified region of the input into raw snippets and
--   subregions to be formatted.
preprocess :: Bool -> RegionDeltas -> Text -> [Either Text RegionDeltas]
instance GHC.Show.Show Ormolu.Processing.Preprocess.OrmoluState
instance GHC.Classes.Eq Ormolu.Processing.Preprocess.OrmoluState


-- | 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, where a branching is
--   not just a binary branching (with a left node, right node, and
--   operator like in the GHC's AST), but rather a n-ary branching, with n
--   + 1 nodes and n operators (n &gt;= 1).
--   
--   This representation allows us to put all the operators with the same
--   precedence level as direct siblings in this tree, to better represent
--   the idea of a chain of operators.
data OpTree ty op

-- | A node which is not an operator application
OpNode :: ty -> OpTree ty op

-- | A subtree of operator application(s); the invariant is: <tt>length
--   exprs == length ops + 1</tt>. <tt>OpBranches [x, y, z] [op1, op2]</tt>
--   represents the expression <tt>x op1 y op2 z</tt>.
OpBranches :: [OpTree ty op] -> [op] -> OpTree ty op

-- | Wrapper for an operator, carrying information about its name and
--   fixity.
data OpInfo op
OpInfo :: op -> Maybe OpName -> FixityInfo -> OpInfo op

-- | The actual operator
[opiOp] :: OpInfo op -> op

-- | Its name, if available. We use 'Maybe OpName' here instead of
--   <a>OpName</a> because the name-fetching function received by
--   <a>reassociateOpTree</a> returns a <a>Maybe</a>
[opiName] :: OpInfo op -> Maybe OpName

-- | Information about the fixity direction and precedence level of the
--   operator
[opiFix] :: OpInfo op -> FixityInfo

-- | Return combined <a>SrcSpan</a>s of all elements in this <a>OpTree</a>.
opTreeLoc :: HasSrcSpan l => OpTree (GenLocated l a) b -> SrcSpan

-- | Re-associate an <a>OpTree</a> taking into account 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) -> FixityMap -> LazyFixityMap -> OpTree ty op -> OpTree ty (OpInfo op)

-- | Indicate if an operator has <tt><a>InfixR</a> 0</tt> fixity. We
--   special-case this class of operators because they often have, like
--   (<a>$</a>), a specific “separator” use-case, and we sometimes format
--   them differently than other operators.
isHardSplitterOp :: FixityInfo -> Bool
instance (GHC.Show.Show ty, GHC.Show.Show op) => GHC.Show.Show (Ormolu.Printer.Operators.OpTree ty op)
instance (GHC.Classes.Eq ty, GHC.Classes.Eq op) => GHC.Classes.Eq (Ormolu.Printer.Operators.OpTree ty op)
instance GHC.Classes.Eq op => GHC.Classes.Eq (Ormolu.Printer.Operators.OpInfo op)


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

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

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

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

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

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


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

-- | Create <a>CommentStream</a> from <a>HsModule</a>. The pragmas are
--   removed from the <a>CommentStream</a>.
mkCommentStream :: Text -> HsModule -> (Maybe (RealLocated Comment), [([RealLocated Comment], Pragma)], CommentStream)

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

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

-- | Get a collection of lines from a <a>Comment</a>.
unComment :: Comment -> NonEmpty Text

-- | Check whether the <a>Comment</a> 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 Data.Data.Data Ormolu.Parser.CommentStream.Comment
instance GHC.Show.Show Ormolu.Parser.CommentStream.Comment
instance GHC.Classes.Eq Ormolu.Parser.CommentStream.Comment
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


-- | 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 <a>R</a> monad.
runR :: R () -> SpanStream -> CommentStream -> SourceType -> EnumSet Extension -> FixityMap -> LazyFixityMap -> 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 ()

-- | Similar to <a>txt</a> but the text inserted this way is assumed to
--   break the “link” between the preceding atom and its pending comments.
interferingTxt :: 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 ()

-- | Return the source type.
askSourceType :: R SourceType

-- | Retrieve fixity overrides map.
askFixityOverrides :: R FixityMap

-- | Retrieve the lazy fixity map.
askFixityMap :: R LazyFixityMap

-- | 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 ()

-- | In rare cases, we have to indent by a positive amount smaller than
--   <a>indentStep</a>.
inciHalf :: 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 ()

-- | <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 ()

-- | 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 <a>RealSrcSpan</a> from <a>SpanMark</a>.
spanMarkSpan :: SpanMark -> RealSrcSpan

-- | 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.
setSpanMark :: SpanMark -> R ()

-- | Get span of last output comment.
getSpanMark :: R (Maybe SpanMark)
isExtensionEnabled :: Extension -> R Bool
instance GHC.Show.Show Ormolu.Printer.Internal.RequestedDelimiter
instance GHC.Classes.Eq Ormolu.Printer.Internal.RequestedDelimiter
instance GHC.Show.Show Ormolu.Printer.Internal.Layout
instance GHC.Classes.Eq Ormolu.Printer.Internal.Layout
instance GHC.Show.Show Ormolu.Printer.Internal.CommentPosition
instance GHC.Classes.Eq Ormolu.Printer.Internal.CommentPosition
instance GHC.Classes.Eq Ormolu.Printer.Internal.SpitType
instance GHC.Show.Show Ormolu.Printer.Internal.SpitType
instance GHC.Base.Monad Ormolu.Printer.Internal.R
instance GHC.Base.Applicative Ormolu.Printer.Internal.R
instance GHC.Base.Functor Ormolu.Printer.Internal.R


-- | 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 :: 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 <a>Comment</a> immediately. This is a low-level printing
--   function.
spitCommentNow :: RealSrcSpan -> Comment -> R ()

-- | Output a <a>Comment</a> at the end of correct line or after it
--   depending on <a>CommentPosition</a>. 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 <a>R</a> monad hosts combinators that allow us to describe how to
--   render AST.
data R a

-- | Run <a>R</a> monad.
runR :: R () -> SpanStream -> CommentStream -> SourceType -> EnumSet Extension -> FixityMap -> LazyFixityMap -> Text

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

-- | 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 ()

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

-- | In rare cases, we have to indent by a positive amount smaller than
--   <a>indentStep</a>.
inciHalf :: R () -> R ()

-- | Return the source type.
askSourceType :: R SourceType

-- | Retrieve fixity overrides map.
askFixityOverrides :: R FixityMap

-- | Retrieve the lazy fixity map.
askFixityMap :: R LazyFixityMap

-- | Enter a <a>GenLocated</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 :: HasSrcSpan l => GenLocated l a -> (a -> R ()) -> R ()

-- | A version of <a>located</a> with arguments flipped.
located' :: HasSrcSpan l => (a -> R ()) -> GenLocated l a -> 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.
sitcc :: R () -> R ()

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

-- | Surround given entity by banana brackets (i.e., from arrow notation.)
banana :: BracketStyle -> 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 ()

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

-- | Print <tt>=</tt>. Do not use <tt><a>txt</a> "="</tt>.
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 <a>RealSrcSpan</a> from <a>SpanMark</a>.
spanMarkSpan :: SpanMark -> RealSrcSpan

-- | 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.
setSpanMark :: SpanMark -> R ()

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

-- | Expression placement. This marks the places where expressions that
--   implement handing forms may use them.
data Placement

-- | Multi-line layout should cause insertion of a newline and indentation
--   bump
Normal :: Placement

-- | Expressions that have hanging form should use it and avoid bumping one
--   level of indentation
Hanging :: Placement

-- | Place a thing that may have a hanging form. This function handles how
--   to separate it from preceding expressions and whether to bump
--   indentation depending on what sort of expression we have.
placeHanging :: Placement -> R () -> R ()
instance GHC.Show.Show Ormolu.Printer.Combinators.BracketStyle
instance GHC.Classes.Eq Ormolu.Printer.Combinators.BracketStyle
instance GHC.Show.Show Ormolu.Printer.Combinators.Placement
instance GHC.Classes.Eq Ormolu.Printer.Combinators.Placement


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

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


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

-- | Outputs the name of the module-like entity, preceeded by the correct
--   prefix ("module" or "signature").
p_hsmodName :: ModuleName -> R ()
p_ieWrappedName :: IEWrappedName RdrName -> R ()

-- | Render a <tt><a>LocatedN</a> <a>RdrName</a></tt>.
p_rdrName :: LocatedN RdrName -> R ()
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_hsDoc :: HaddockStyle -> Bool -> LHsDoc GhcPs -> R ()

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


-- | Rendering of types.
module Ormolu.Printer.Meat.Type
p_hsType :: HsType GhcPs -> R ()
p_hsTypePostDoc :: 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 :: IsInferredTyVarBndr flag => HsTyVarBndr flag GhcPs -> R ()
data ForAllVisibility
ForAllInvis :: ForAllVisibility
ForAllVis :: ForAllVisibility

-- | Render several <tt>forall</tt>-ed variables.
p_forallBndrs :: HasSrcSpan l => ForAllVisibility -> (a -> R ()) -> [GenLocated l a] -> R ()
p_conDeclFields :: [LConDeclField GhcPs] -> R ()
p_lhsTypeArg :: LHsTypeArg GhcPs -> R ()
p_hsSigType :: HsSigType GhcPs -> R ()
tyVarsToTyPats :: LHsQTyVars GhcPs -> HsTyPats GhcPs
hsOuterTyVarBndrsToHsType :: HsOuterTyVarBndrs Specificity GhcPs -> LHsType GhcPs -> HsType GhcPs
lhsTypeToSigType :: LHsType GhcPs -> LHsSigType GhcPs
instance Ormolu.Printer.Meat.Type.IsInferredTyVarBndr ()
instance Ormolu.Printer.Meat.Type.IsInferredTyVarBndr GHC.Types.Var.Specificity

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 GhcPs -> 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 :: LocatedN RdrName -> LexicalFixity -> LHsQTyVars GhcPs -> LHsType GhcPs -> R ()


-- | Type signature declarations.
module Ormolu.Printer.Meat.Declaration.Signature
p_sigDecl :: Sig GhcPs -> R ()
p_typeAscription :: LHsSigType 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 -> LocatedN RdrName -> HsTyPats GhcPs -> LexicalFixity -> HsDataDefn GhcPs -> R ()

module Ormolu.Printer.Meat.Declaration.Value
p_valDecl :: HsBind GhcPs -> R ()
p_pat :: Pat GhcPs -> R ()
p_hsExpr :: HsExpr GhcPs -> R ()
p_hsSplice :: HsSplice GhcPs -> R ()

-- | Print the source text of a string literal while indenting gaps
--   correctly.
p_stringLit :: String -> R ()
p_hsExpr' :: BracketStyle -> HsExpr GhcPs -> R ()

-- | Print a top-level command.
p_hsCmdTop :: BracketStyle -> HsCmdTop GhcPs -> R ()

-- | Check if given expression has a hanging form.
exprPlacement :: HsExpr GhcPs -> Placement

-- | Determine placement of a top level command.
cmdTopPlacement :: HsCmdTop GhcPs -> Placement

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

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


-- | Printing of operator trees.
module Ormolu.Printer.Meat.Declaration.OpTree

-- | Print an operator tree where leaves are values.
p_exprOpTree :: BracketStyle -> OpTree (LHsExpr GhcPs) (OpInfo (LHsExpr GhcPs)) -> R ()

-- | Convert a <a>LHsExpr</a> containing an operator tree to the
--   <a>OpTree</a> intermediate representation.
exprOpTree :: LHsExpr GhcPs -> OpTree (LHsExpr GhcPs) (LHsExpr GhcPs)

-- | Print an operator tree where leaves are commands.
p_cmdOpTree :: BracketStyle -> OpTree (LHsCmdTop GhcPs) (OpInfo (LHsExpr GhcPs)) -> R ()

-- | Convert a <a>LHsCmdTop</a> containing an operator tree to the
--   <a>OpTree</a> intermediate representation.
cmdOpTree :: LHsCmdTop GhcPs -> OpTree (LHsCmdTop GhcPs) (LHsExpr GhcPs)

-- | Print an operator tree where leaves are types.
p_tyOpTree :: OpTree (LHsType GhcPs) (OpInfo (LocatedN RdrName)) -> R ()

-- | Convert a LHsType containing an operator tree to the <a>OpTree</a>
--   intermediate representation.
tyOpTree :: LHsType GhcPs -> OpTree (LHsType GhcPs) (LocatedN RdrName)

-- | Extract the operator name of the specified <a>HsExpr</a> if this
--   expression corresponds to an operator.
getOpName :: HsExpr GhcPs -> Maybe RdrName

-- | Convert an operator name to a <a>String</a>.
getOpNameStr :: RdrName -> String

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 :: Maybe (LHsContext GhcPs) -> LocatedN RdrName -> LHsQTyVars GhcPs -> LexicalFixity -> [LHsFunDep GhcPs] -> [LSig GhcPs] -> LHsBinds GhcPs -> [LFamilyDecl GhcPs] -> [LTyFamDefltDecl GhcPs] -> [LDocDecl GhcPs] -> 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


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

-- | Render a module-like entity (either a regular module or a backpack
--   signature).
p_hsModule :: Maybe (RealLocated Comment) -> [([RealLocated Comment], Pragma)] -> HsModule -> R ()


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

-- | Either a <a>ParseResult</a>, or a raw snippet.
data SourceSnippet
RawSnippet :: Text -> SourceSnippet
ParsedSnippet :: ParseResult -> SourceSnippet

-- | A collection of data that represents a parsed module in Ormolu.
data ParseResult
ParseResult :: HsModule -> SourceType -> Maybe (RealLocated Comment) -> [([RealLocated Comment], Pragma)] -> CommentStream -> EnumSet Extension -> FixityMap -> LazyFixityMap -> Int -> ParseResult

-- | Parsed module or signature
[prParsedSource] :: ParseResult -> HsModule

-- | Either regular module or signature file
[prSourceType] :: ParseResult -> SourceType

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

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

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

-- | Enabled extensions
[prExtensions] :: ParseResult -> EnumSet Extension

-- | Fixity overrides
[prFixityOverrides] :: ParseResult -> FixityMap

-- | Fixity map for operators
[prFixityMap] :: ParseResult -> LazyFixityMap

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


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

-- | Render several source snippets.
printSnippets :: [SourceSnippet] -> Text


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

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


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

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

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


-- | This module allows us to diff two <a>ParseResult</a>s.
module Ormolu.Diff.ParseResult

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

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

-- | Two parse results differ
Different :: [RealSrcSpan] -> ParseResultDiff

-- | Return <tt>Diff</tt> of two <a>ParseResult</a>s.
diffParseResult :: ParseResult -> ParseResult -> ParseResultDiff
instance GHC.Show.Show Ormolu.Diff.ParseResult.ParseResultDiff
instance GHC.Base.Semigroup Ormolu.Diff.ParseResult.ParseResultDiff
instance GHC.Base.Monoid Ormolu.Diff.ParseResult.ParseResultDiff

module Ormolu.Utils.Cabal

-- | The result of searching for a <tt>.cabal</tt> file.
data CabalSearchResult

-- | Cabal file could not be found
CabalNotFound :: CabalSearchResult

-- | Cabal file was found, but it did not mention the source file in
--   question
CabalDidNotMention :: CabalInfo -> CabalSearchResult

-- | Cabal file was found and it mentions the source file in question
CabalFound :: CabalInfo -> CabalSearchResult

-- | Cabal information of interest to Ormolu.
data CabalInfo
CabalInfo :: !PackageName -> ![DynOption] -> !Set PackageName -> !FilePath -> CabalInfo

-- | Package name
[ciPackageName] :: CabalInfo -> !PackageName

-- | Extension and language settings in the form of <a>DynOption</a>s
[ciDynOpts] :: CabalInfo -> ![DynOption]

-- | Direct dependencies
[ciDependencies] :: CabalInfo -> !Set PackageName

-- | Absolute path to the cabal file
[ciCabalFilePath] :: CabalInfo -> !FilePath

-- | This represents language extensions beyond a base <a>Language</a>
--   definition (such as <a>Haskell98</a>) that are supported by some
--   implementations, usually in some special mode.
--   
--   Where applicable, references are given to an implementation's official
--   documentation.
data () => Extension

-- | Enable a known extension
EnableExtension :: KnownExtension -> Extension

-- | Disable a known extension
DisableExtension :: KnownExtension -> Extension

-- | An unknown extension, identified by the name of its <tt>LANGUAGE</tt>
--   pragma.
UnknownExtension :: String -> Extension

-- | Locate a <tt>.cabal</tt> file corresponding to the given Haskell
--   source file and obtain <a>CabalInfo</a> from it.
getCabalInfoForSourceFile :: MonadIO m => FilePath -> m CabalSearchResult

-- | Find the path to an appropriate .cabal file for a Haskell source file,
--   if available.
findCabalFile :: MonadIO m => FilePath -> m (Maybe FilePath)

-- | Parse <a>CabalInfo</a> from a .cabal file at the given
--   <a>FilePath</a>.
parseCabalInfo :: MonadIO m => FilePath -> FilePath -> m (Bool, CabalInfo)
instance GHC.Show.Show Ormolu.Utils.Cabal.CabalInfo
instance GHC.Classes.Eq Ormolu.Utils.Cabal.CabalInfo
instance GHC.Show.Show Ormolu.Utils.Cabal.CabalSearchResult
instance GHC.Classes.Eq Ormolu.Utils.Cabal.CabalSearchResult
instance GHC.Show.Show Ormolu.Utils.Cabal.CachedCabalFile


-- | Write <a>Text</a> to files using UTF8 and ignoring native line ending
--   conventions.
module Ormolu.Utils.IO

-- | Write a <a>Text</a> to a file using UTF8 and ignoring native line
--   ending conventions.
writeFileUtf8 :: MonadIO m => FilePath -> Text -> m ()

-- | Read an entire file strictly into a <a>Text</a> using UTF8 and
--   ignoring native line ending conventions.
readFileUtf8 :: MonadIO m => FilePath -> m Text

-- | Read stdin as UTF8-encoded <a>Text</a> value.
getContentsUtf8 :: MonadIO m => m Text

module Ormolu.Utils.Fixity

-- | Attempt to locate and parse an <tt>.ormolu</tt> file. If it does not
--   exist, empty fixity map is returned. This function maintains a cache
--   of fixity overrides where cabal file paths act as keys.
getFixityOverridesForSourceFile :: MonadIO m => CabalInfo -> m FixityMap

-- | A wrapper around <a>parseFixityDeclaration</a> for parsing individual
--   fixity definitions.
parseFixityDeclarationStr :: String -> Either String [(OpName, FixityInfo)]


-- | A formatter for Haskell source code. This module exposes the official
--   stable API, other modules may be not as reliable.
module Ormolu

-- | Format a <a>Text</a>.
--   
--   The function
--   
--   <ul>
--   <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>
--   
--   <b>NOTE</b>: The caller is responsible for setting the appropriate
--   value in the <a>cfgSourceType</a> field. Autodetection of source type
--   won't happen here, see <a>detectSourceType</a>.
ormolu :: MonadIO m => Config RegionIndices -> FilePath -> Text -> m Text

-- | Load a file and format it. The file stays intact and the rendered
--   version is returned as <a>Text</a>.
--   
--   <b>NOTE</b>: The caller is responsible for setting the appropriate
--   value in the <a>cfgSourceType</a> field. Autodetection of source type
--   won't happen here, see <a>detectSourceType</a>.
ormoluFile :: MonadIO m => Config RegionIndices -> FilePath -> m Text

-- | Read input from stdin and format it.
--   
--   <b>NOTE</b>: The caller is responsible for setting the appropriate
--   value in the <a>cfgSourceType</a> field. Autodetection of source type
--   won't happen here, see <a>detectSourceType</a>.
ormoluStdin :: MonadIO m => Config RegionIndices -> m Text

-- | Ormolu configuration.
data Config region
Config :: ![DynOption] -> FixityMap -> !Set PackageName -> !Bool -> !Bool -> !Bool -> !SourceType -> !ColorMode -> !region -> Config region

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

-- | Fixity overrides
[cfgFixityOverrides] :: Config region -> FixityMap

-- | Known dependencies, if any
[cfgDependencies] :: Config region -> !Set PackageName

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

-- | How to parse the input (regular haskell module or Backpack file)
[cfgSourceType] :: Config region -> !SourceType

-- | Whether to use colors and other features of ANSI terminals
[cfgColorMode] :: Config region -> !ColorMode

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

-- | Whether to use colors and other features of ANSI terminals.
data ColorMode
Never :: ColorMode
Always :: ColorMode
Auto :: ColorMode

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

-- | Type of sources that can be formatted by Ormolu.
data SourceType

-- | Consider the input as a regular Haskell module
ModuleSource :: SourceType

-- | Consider the input as a Backpack module signature
SignatureSource :: SourceType

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

-- | Detect <a>SourceType</a> based on the file extension.
detectSourceType :: FilePath -> SourceType

-- | Refine a <a>Config</a> by incorporating given <a>SourceType</a>,
--   <tt>CabalInfo</tt>, and fixity overrides <a>FixityMap</a>. You can use
--   <a>detectSourceType</a> to deduce <a>SourceType</a> based on the file
--   extension, <a>getCabalInfoForSourceFile</a> to obtain
--   <tt>CabalInfo</tt> and <a>getFixityOverridesForSourceFile</a> for
--   <a>FixityMap</a>.
refineConfig :: SourceType -> Maybe CabalInfo -> Maybe FixityMap -> Config region -> Config region

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

-- | The result of searching for a <tt>.cabal</tt> file.
data CabalSearchResult

-- | Cabal file could not be found
CabalNotFound :: CabalSearchResult

-- | Cabal file was found, but it did not mention the source file in
--   question
CabalDidNotMention :: CabalInfo -> CabalSearchResult

-- | Cabal file was found and it mentions the source file in question
CabalFound :: CabalInfo -> CabalSearchResult

-- | Cabal information of interest to Ormolu.
data CabalInfo
CabalInfo :: !PackageName -> ![DynOption] -> !Set PackageName -> !FilePath -> CabalInfo

-- | Package name
[ciPackageName] :: CabalInfo -> !PackageName

-- | Extension and language settings in the form of <a>DynOption</a>s
[ciDynOpts] :: CabalInfo -> ![DynOption]

-- | Direct dependencies
[ciDependencies] :: CabalInfo -> !Set PackageName

-- | Absolute path to the cabal file
[ciCabalFilePath] :: CabalInfo -> !FilePath

-- | Locate a <tt>.cabal</tt> file corresponding to the given Haskell
--   source file and obtain <a>CabalInfo</a> from it.
getCabalInfoForSourceFile :: MonadIO m => FilePath -> m CabalSearchResult

-- | Map from the operator name to its <a>FixityInfo</a>.
type FixityMap = Map OpName FixityInfo

-- | Attempt to locate and parse an <tt>.ormolu</tt> file. If it does not
--   exist, empty fixity map is returned. This function maintains a cache
--   of fixity overrides where cabal file paths act as keys.
getFixityOverridesForSourceFile :: MonadIO m => CabalInfo -> m FixityMap

-- | 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 :: TextDiff -> [RealSrcSpan] -> OrmoluException

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

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

-- | Cabal file parsing failed
OrmoluCabalFileParsingFailed :: FilePath -> OrmoluException

-- | Missing input file path when using stdin input and accounting for
--   .cabal files
OrmoluMissingStdinInputFile :: OrmoluException

-- | A parse error in a fixity overrides file
OrmoluFixityOverridesParseError :: ParseErrorBundle Text Void -> OrmoluException

-- | Inside this wrapper <a>OrmoluException</a> will be caught and
--   displayed nicely.
withPrettyOrmoluExceptions :: ColorMode -> IO ExitCode -> IO ExitCode
