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

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

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

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

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

-- | Return an IntSet containing all lines which are affected by
--   CPP.
cppLines :: Text -> IntSet

-- | Replace all lines affected by CPP with blank lines.
eraseCppLines :: Text -> Text
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 RelativePoses to elements of a given list.
attachRelativePos :: [a] -> [(RelativePos, a)]

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

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

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

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

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

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

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

-- | Return True if one span ends on the same line the second one
--   starts.
onTheSameLine :: SrcSpan -> SrcSpan -> Bool
class HasSrcSpan l
loc' :: HasSrcSpan l => l -> SrcSpan
getLoc' :: HasSrcSpan l => GenLocated l a -> SrcSpan

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

-- | Convert Text to a StringBuffer by making a copy.
textToStringBuffer :: Text -> StringBuffer

-- | Convert GHC's ModuleName into the one used by Cabal.
ghcModuleNameToCabal :: ModuleName -> ModuleName
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
type Term = TermOutput ()

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

-- | Run Term monad.
runTerm :: Term -> ColorMode -> Handle -> IO ()
runTermPure :: Term -> Text

-- | Make the output bold text.
bold :: Term -> Term

-- | Make the output cyan text.
cyan :: Term -> Term

-- | Make the output green text.
green :: Term -> Term

-- | Make the output red text.
red :: Term -> Term

-- | Output Text.
put :: Text -> Term

-- | Output a Show value.
putShow :: Show a => a -> Term

-- | Output an Outputable value.
putOutputable :: Outputable a => a -> Term

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

module Ormolu.Terminal.QualifiedDo
(>>) :: Term -> Term -> Term

-- | This module allows us to diff two Text values.
module Ormolu.Diff.Text

-- | Result of diffing two Texts.
data TextDiff

-- | Diff two texts and produce a TextDiff.
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 TextDiff as a Term action. This function
--   tries to mimic the style of git diff.
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

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

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

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

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

-- | Original and resulting ASTs differ
OrmoluASTDiffers :: 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 -> NonEmpty PError -> 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 OrmoluException.
printOrmoluException :: OrmoluException -> Term

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

-- | 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 Nothing
--   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 RealLocated Comments in ascending order with
--   respect to beginning of corresponding spans.
newtype CommentStream
CommentStream :: [LComment] -> CommentStream

-- | Create CommentStream from HsModule. The pragmas are
--   removed from the CommentStream.
mkCommentStream :: Text -> HsModule GhcPs -> (Maybe LComment, [([LComment], Pragma)], CommentStream)
type LComment = RealLocated Comment

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

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

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

-- | Is this comment multiline-style?
isMultilineComment :: Comment -> Bool
instance 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

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

-- | Sort and normalize imports.
normalizeImports :: [LImportDecl GhcPs] -> [LImportDecl GhcPs]
instance GHC.Classes.Ord Ormolu.Imports.ImportPkgQual
instance GHC.Classes.Eq Ormolu.Imports.ImportPkgQual
instance GHC.Classes.Eq Ormolu.Imports.ImportListInterpretationOrd
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
instance GHC.Classes.Ord Ormolu.Imports.ImportListInterpretationOrd

module Ormolu.Fixity.Internal

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

-- | Convert an OpName to Text.
unOpName :: OpName -> Text

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

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

-- | Fixity information about an infix operator. This type provides precise
--   information as opposed to FixityApproximation.
data FixityInfo
FixityInfo :: FixityDirection -> Int -> FixityInfo

-- | Fixity direction
[fiDirection] :: FixityInfo -> FixityDirection

-- | Precedence
[fiPrecedence] :: FixityInfo -> Int

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

-- | Fixity that is implicitly assumed if no fixity declaration is present.
defaultFixityInfo :: FixityInfo

-- | Approximation of fixity information that takes the uncertainty that
--   can arise from conflicting definitions into account.
data FixityApproximation
FixityApproximation :: Maybe FixityDirection -> Int -> Int -> FixityApproximation

-- | Fixity direction if it is known
[faDirection] :: FixityApproximation -> Maybe FixityDirection

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

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

-- | The lowest level of information we can have about an operator.
defaultFixityApproximation :: FixityApproximation

-- | The map of operators declared by each package grouped by module name.
newtype HackageInfo
HackageInfo :: Map PackageName (Map ModuleName (Map OpName FixityInfo)) -> HackageInfo

-- | Map from the operator name to its FixityInfo.
newtype FixityOverrides
FixityOverrides :: Map OpName FixityInfo -> FixityOverrides
[unFixityOverrides] :: FixityOverrides -> Map OpName FixityInfo

-- | Fixity overrides to use by default.
defaultFixityOverrides :: FixityOverrides

-- | Module re-exports
newtype ModuleReexports
ModuleReexports :: Map ModuleName (NonEmpty (Maybe PackageName, ModuleName)) -> ModuleReexports
[unModuleReexports] :: ModuleReexports -> Map ModuleName (NonEmpty (Maybe PackageName, ModuleName))

-- | Module re-exports to apply by default.
defaultModuleReexports :: ModuleReexports

-- | Fixity information that is specific to a package being formatted. It
--   requires module-specific imports in order to be usable.
newtype PackageFixityMap
PackageFixityMap :: Map OpName (NonEmpty (PackageName, ModuleName, FixityInfo)) -> PackageFixityMap

-- | Fixity map that takes into account imports in a particular module.
newtype ModuleFixityMap
ModuleFixityMap :: Map OpName FixityProvenance -> ModuleFixityMap

-- | Provenance of fixity info.
data FixityProvenance

-- | FixityInfo of a built-in operator or provided by a user
--   override.
Given :: FixityInfo -> FixityProvenance

-- | FixityInfo to be inferred from module imports.
FromModuleImports :: NonEmpty (FixityQualification, FixityInfo) -> FixityProvenance

-- | Fixity qualification that determines how FixityInfo matches a
--   particular use of an operator, given whether it is qualified or
--   unqualified and the module name used.
data FixityQualification
UnqualifiedAndQualified :: ModuleName -> FixityQualification
OnlyQualified :: ModuleName -> FixityQualification

-- | Get a FixityApproximation of an operator.
inferFixity :: RdrName -> ModuleFixityMap -> FixityApproximation
instance Control.DeepSeq.NFData Ormolu.Fixity.Internal.OpName
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 Control.DeepSeq.NFData Ormolu.Fixity.Internal.FixityDirection
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 Control.DeepSeq.NFData Ormolu.Fixity.Internal.FixityInfo
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 Control.DeepSeq.NFData Ormolu.Fixity.Internal.FixityApproximation
instance Data.Binary.Class.Binary Ormolu.Fixity.Internal.FixityApproximation
instance GHC.Generics.Generic Ormolu.Fixity.Internal.FixityApproximation
instance GHC.Show.Show Ormolu.Fixity.Internal.FixityApproximation
instance GHC.Classes.Ord Ormolu.Fixity.Internal.FixityApproximation
instance GHC.Classes.Eq Ormolu.Fixity.Internal.FixityApproximation
instance Control.DeepSeq.NFData Ormolu.Fixity.Internal.HackageInfo
instance Data.Binary.Class.Binary Ormolu.Fixity.Internal.HackageInfo
instance GHC.Generics.Generic Ormolu.Fixity.Internal.HackageInfo
instance GHC.Show.Show Ormolu.Fixity.Internal.FixityOverrides
instance GHC.Classes.Eq Ormolu.Fixity.Internal.FixityOverrides
instance GHC.Show.Show Ormolu.Fixity.Internal.ModuleReexports
instance GHC.Classes.Eq Ormolu.Fixity.Internal.ModuleReexports
instance GHC.Show.Show Ormolu.Fixity.Internal.PackageFixityMap
instance GHC.Classes.Eq Ormolu.Fixity.Internal.PackageFixityMap
instance GHC.Show.Show Ormolu.Fixity.Internal.FixityQualification
instance GHC.Classes.Eq Ormolu.Fixity.Internal.FixityQualification
instance GHC.Show.Show Ormolu.Fixity.Internal.FixityProvenance
instance GHC.Classes.Eq Ormolu.Fixity.Internal.FixityProvenance
instance GHC.Show.Show Ormolu.Fixity.Internal.ModuleFixityMap
instance GHC.Classes.Eq Ormolu.Fixity.Internal.ModuleFixityMap
instance GHC.Base.Semigroup Ormolu.Fixity.Internal.FixityApproximation
instance GHC.Show.Show Ormolu.Fixity.Internal.OpName
instance Data.String.IsString Ormolu.Fixity.Internal.OpName

-- | Simplified representation of the import list for the purposes of
--   fixity inference.
module Ormolu.Fixity.Imports

-- | Simplified info about an import.
data FixityImport
FixityImport :: !Maybe PackageName -> !ModuleName -> !FixityQualification -> !Maybe (ImportListInterpretation, [OpName]) -> FixityImport
[fimportPackage] :: FixityImport -> !Maybe PackageName
[fimportModule] :: FixityImport -> !ModuleName
[fimportQualified] :: FixityImport -> !FixityQualification
[fimportList] :: FixityImport -> !Maybe (ImportListInterpretation, [OpName])

-- | Extract FixityImports from the AST.
extractFixityImports :: [LImportDecl GhcPs] -> [FixityImport]

-- | Apply given module re-exports.
applyModuleReexports :: ModuleReexports -> [FixityImport] -> [FixityImport]

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

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

-- | Convert an OpName to Text.
unOpName :: OpName -> Text

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

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

-- | Fixity information about an infix operator. This type provides precise
--   information as opposed to FixityApproximation.
data FixityInfo
FixityInfo :: FixityDirection -> Int -> FixityInfo

-- | Fixity direction
[fiDirection] :: FixityInfo -> FixityDirection

-- | Precedence
[fiPrecedence] :: FixityInfo -> Int

-- | Fixity that is implicitly assumed if no fixity declaration is present.
defaultFixityInfo :: FixityInfo

-- | Approximation of fixity information that takes the uncertainty that
--   can arise from conflicting definitions into account.
data FixityApproximation
FixityApproximation :: Maybe FixityDirection -> Int -> Int -> FixityApproximation

-- | Fixity direction if it is known
[faDirection] :: FixityApproximation -> Maybe FixityDirection

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

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

-- | The lowest level of information we can have about an operator.
defaultFixityApproximation :: FixityApproximation

-- | Map from the operator name to its FixityInfo.
newtype FixityOverrides
FixityOverrides :: Map OpName FixityInfo -> FixityOverrides
[unFixityOverrides] :: FixityOverrides -> Map OpName FixityInfo

-- | Fixity overrides to use by default.
defaultFixityOverrides :: FixityOverrides

-- | Module re-exports
newtype ModuleReexports
ModuleReexports :: Map ModuleName (NonEmpty (Maybe PackageName, ModuleName)) -> ModuleReexports
[unModuleReexports] :: ModuleReexports -> Map ModuleName (NonEmpty (Maybe PackageName, ModuleName))

-- | Module re-exports to apply by default.
defaultModuleReexports :: ModuleReexports

-- | Fixity information that is specific to a package being formatted. It
--   requires module-specific imports in order to be usable.
newtype PackageFixityMap
PackageFixityMap :: Map OpName (NonEmpty (PackageName, ModuleName, FixityInfo)) -> PackageFixityMap

-- | Fixity map that takes into account imports in a particular module.
newtype ModuleFixityMap
ModuleFixityMap :: Map OpName FixityProvenance -> ModuleFixityMap

-- | Get a FixityApproximation of an operator.
inferFixity :: RdrName -> ModuleFixityMap -> FixityApproximation

-- | The map of operators declared by each package grouped by module name.
newtype HackageInfo
HackageInfo :: Map PackageName (Map ModuleName (Map OpName FixityInfo)) -> HackageInfo

-- | The built-in HackageInfo used by Ormolu.
hackageInfo :: HackageInfo

-- | Default set of packages to assume as dependencies e.g. when no Cabal
--   file is found or taken into consideration.
defaultDependencies :: Set PackageName

-- | Compute the fixity map that is specific to the package we are
--   formatting.
packageFixityMap :: Set PackageName -> PackageFixityMap

-- | The same as packageFixityMap, except this specific version of
--   the function allows the user to specify HackageInfo used to
--   build the final fixity map.
packageFixityMap' :: HackageInfo -> Set PackageName -> PackageFixityMap

-- | Compute the fixity map that is specific to the module we are
--   formatting.
moduleFixityMap :: PackageFixityMap -> [FixityImport] -> ModuleFixityMap

-- | Apply fixity overrides.
applyFixityOverrides :: FixityOverrides -> ModuleFixityMap -> ModuleFixityMap

-- | 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 >= 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: length
--   exprs == length ops + 1. OpBranches [x, y, z] [op1, op2]
--   represents the expression x op1 y op2 z.
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 RdrName -> FixityApproximation -> OpInfo op

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

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

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

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

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

-- | Indicate if an operator has InfixR 0 fixity. We
--   special-case this class of operators because they often have, like
--   ($), a specific “separator” use-case, and we sometimes format
--   them differently than other operators.
isHardSplitterOp :: FixityApproximation -> 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)

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

-- | Print out a textual representation of an .ormolu file.
printDotOrmolu :: FixityOverrides -> ModuleReexports -> Text

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

-- | Parse textual representation of FixityOverrides.
parseDotOrmolu :: FilePath -> Text -> Either (ParseErrorBundle Text Void) (FixityOverrides, ModuleReexports)

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

-- | Parse a single self-contained module re-export declaration.
parseModuleReexportDeclaration :: Text -> Either (ParseErrorBundle Text Void) (ModuleName, NonEmpty (Maybe PackageName, ModuleName))

-- | Parse a single fixity declaration, such as
--   
--   
--   infixr 4 +++, >>>
--   
pFixity :: Parser [(OpName, FixityInfo)]

-- | See
--   https://www.haskell.org/onlinereport/haskell2010/haskellch2.html
pOperator :: Parser OpName
pModuleName :: Parser ModuleName
pPackageName :: Parser PackageName
isIdentifierFirstChar :: Char -> Bool
isIdentifierConstituent :: Char -> Bool
isOperatorConstituent :: Char -> Bool
isPackageNameConstituent :: Char -> Bool
isModuleSegmentFirstChar :: Char -> Bool
isModuleSegmentConstituent :: Char -> Bool

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

-- | Ormolu configuration.
data Config region
Config :: ![DynOption] -> !FixityOverrides -> !ModuleReexports -> !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 -> !FixityOverrides

-- | Module reexports to take into account when doing fixity resolution
[cfgModuleReexports] :: Config region -> !ModuleReexports

-- | 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 Config RegionIndices.
defaultConfig :: Config RegionIndices

-- | Return all dependencies of the module. This includes both the declared
--   dependencies of the component we are working with and all potential
--   module re-export targets.
overapproximatedDependencies :: Config region -> Set PackageName

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

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

-- | Convert DynOption to Located String.
dynOptionToLocatedStr :: DynOption -> Located String
instance GHC.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 Text. Return the input with
--   indentation removed and the detected indentation level.
removeIndentation :: Text -> (Text, Int)

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

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

-- | Convert a set of line indices into disjoint RegionDeltas
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

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

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

-- | Run R monad.
runR :: R () -> SpanStream -> CommentStream -> SourceType -> EnumSet Extension -> ModuleFixityMap -> Text

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

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

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

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

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

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

-- | Retrieve the module fixity map.
askModuleFixityMap :: R ModuleFixityMap

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

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

-- | Layout options.
data Layout

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

-- | Use multiple lines
MultiLine :: Layout

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | Get the immediately enclosing RealSrcSpan.
getEnclosingSpan :: R (Maybe RealSrcSpan)

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

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

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

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

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

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

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

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

-- | Haddock string style.
data HaddockStyle

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

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

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

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

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

-- | Get span of last output comment.
getSpanMark :: R (Maybe SpanMark)
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
--   Ormolu.Printer.Combinators unless you know what you are doing.
module Ormolu.Printer.Comments

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

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

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

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

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

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

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

-- | Run R monad.
runR :: R () -> SpanStream -> CommentStream -> SourceType -> EnumSet Extension -> ModuleFixityMap -> Text

-- | Get the immediately enclosing RealSrcSpan.
getEnclosingSpan :: R (Maybe RealSrcSpan)

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

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

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

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

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

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

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

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

-- | Retrieve the module fixity map.
askModuleFixityMap :: R ModuleFixityMap

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

-- | Similar to located, but when the "payload" is an empty list,
--   print virtual elements at the start and end of the source span to
--   prevent comments from "floating out".
encloseLocated :: HasSrcSpan l => GenLocated l [a] -> ([a] -> R ()) -> R ()

-- | A version of located with arguments flipped.
located' :: HasSrcSpan l => (a -> R ()) -> GenLocated l a -> R ()

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

-- | Layout options.
data Layout

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

-- | Use multiple lines
MultiLine :: Layout

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

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

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

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

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

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

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

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

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

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

-- | Normal
N :: BracketStyle

-- | Shifted one level
S :: BracketStyle

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

-- | Haddock string style.
data HaddockStyle

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

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

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

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

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

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

-- | 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 Pragmas with their associated comments.
p_pragmas :: [([LComment], 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 GhcPs -> R ()

-- | Render a LocatedN RdrName.
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 ()

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

-- | Render several forall-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_hsUntypedSplice :: SpliceDecoration -> HsUntypedSplice GhcPs -> R ()

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

-- | An applicand is the left-hand side in a function application, i.e.
--   f in f a. We need to track this in order to add
--   extra identation in cases like
--   
--   
--   foo =
--     do
--         succ
--       1
--   
data IsApplicand
Applicand :: IsApplicand
NotApplicand :: IsApplicand
p_hsExpr' :: IsApplicand -> 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 LHsExpr containing an operator tree to the
--   OpTree 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 LHsCmdTop containing an operator tree to the
--   OpTree 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 OpTree
--   intermediate representation.
tyOpTree :: LHsType GhcPs -> OpTree (LHsType GhcPs) (LocatedN RdrName)

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

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

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

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

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

-- | Either a ParseResult, 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 GhcPs -> SourceType -> Maybe LComment -> [([LComment], Pragma)] -> CommentStream -> EnumSet Extension -> ModuleFixityMap -> Int -> ParseResult

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

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

-- | Stack header
[prStackHeader] :: ParseResult -> Maybe LComment

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

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

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

-- | Fixity map for operators
[prModuleFixityMap] :: ParseResult -> ModuleFixityMap

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

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

-- | Parse a complete module from Text.
parseModule :: MonadIO m => Config RegionDeltas -> PackageFixityMap -> 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 ParseResults.
module Ormolu.Diff.ParseResult

-- | Result of comparing two ParseResults.
data ParseResultDiff

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

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

-- | Return Diff of two ParseResults.
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

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

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

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

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

-- | Find the path to the closest file higher in the file hierarchy that
--   satisfies a given predicate.
findClosestFileSatisfying :: MonadIO m => (FilePath -> Bool) -> FilePath -> m (Maybe FilePath)

-- | Execute an IO action but only if the given key is not found in
--   the IORef cache.
withIORefCache :: Ord k => IORef (Map k v) -> k -> IO v -> IO v

module Ormolu.Utils.Fixity

-- | Attempt to locate and parse an .ormolu file. If it does not
--   exist, default fixity map and module reexports are returned. This
--   function maintains a cache of fixity overrides and module re-exports
--   where cabal file paths act as keys.
getDotOrmoluForSourceFile :: MonadIO m => FilePath -> m (FixityOverrides, ModuleReexports)

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

-- | A wrapper around parseModuleReexportDeclaration for parsing a
--   individual module reexport.
parseModuleReexportDeclarationStr :: String -> Either String (ModuleName, NonEmpty (Maybe PackageName, ModuleName))

module Ormolu.Utils.Cabal

-- | The result of searching for a .cabal 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 DynOptions
[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 Language
--   definition (such as Haskell98) 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 LANGUAGE
--   pragma.
UnknownExtension :: String -> Extension

-- | Locate a .cabal file corresponding to the given Haskell
--   source file and obtain CabalInfo 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 CabalInfo from a .cabal file at the given
--   FilePath.
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

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

-- | Format a Text.
--   
--   The function
--   
--   
--   
- Needs IO because some functions from GHC that are necessary
--   to setup parsing context require IO. There should be no visible
--   side-effects though.
--   
- Takes file name just to use it in parse error messages.
--   
- Throws OrmoluException.
--   
--   
--   NOTE: The caller is responsible for setting the appropriate
--   value in the cfgSourceType field. Autodetection of source type
--   won't happen here, see detectSourceType.
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 Text.
--   
--   NOTE: The caller is responsible for setting the appropriate
--   value in the cfgSourceType field. Autodetection of source type
--   won't happen here, see detectSourceType.
ormoluFile :: MonadIO m => Config RegionIndices -> FilePath -> m Text

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

-- | Ormolu configuration.
data Config region
Config :: ![DynOption] -> !FixityOverrides -> !ModuleReexports -> !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 -> !FixityOverrides

-- | Module reexports to take into account when doing fixity resolution
[cfgModuleReexports] :: Config region -> !ModuleReexports

-- | 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 Config RegionIndices.
defaultConfig :: Config RegionIndices

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

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

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

-- | The result of searching for a .cabal 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 DynOptions
[ciDynOpts] :: CabalInfo -> ![DynOption]

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

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

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

-- | Map from the operator name to its FixityInfo.
data FixityOverrides

-- | Fixity overrides to use by default.
defaultFixityOverrides :: FixityOverrides

-- | Module re-exports
data ModuleReexports

-- | Module re-exports to apply by default.
defaultModuleReexports :: ModuleReexports

-- | Attempt to locate and parse an .ormolu file. If it does not
--   exist, default fixity map and module reexports are returned. This
--   function maintains a cache of fixity overrides and module re-exports
--   where cabal file paths act as keys.
getDotOrmoluForSourceFile :: MonadIO m => FilePath -> m (FixityOverrides, ModuleReexports)

-- | 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 -> NonEmpty PError -> 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 OrmoluException will be caught and
--   displayed nicely.
withPrettyOrmoluExceptions :: ColorMode -> IO ExitCode -> IO ExitCode
