{-# LANGUAGE RecordWildCards #-}
module Ormolu.Printer
( printModule,
)
where
import Data.Text (Text)
import Ormolu.Parser.Result
import Ormolu.Printer.Combinators
import Ormolu.Printer.Meat.Module
import Ormolu.Printer.SpanStream
import Ormolu.Processing.Postprocess (postprocess)
printModule ::
ParseResult ->
Text
printModule :: ParseResult -> Text
printModule ParseResult {..} =
Text
prLiteralPrefix Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
region Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
prLiteralSuffix
where
region :: Text
region =
Int -> Text -> Text
postprocess Int
prIndent (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
$
R () -> SpanStream -> CommentStream -> Anns -> Bool -> Text
runR
( Maybe (RealLocated Comment)
-> [Shebang]
-> [([RealLocated Comment], Pragma)]
-> Bool
-> HsModule GhcPs
-> R ()
p_hsModule
Maybe (RealLocated Comment)
prStackHeader
[Shebang]
prShebangs
[([RealLocated Comment], Pragma)]
prPragmas
Bool
prImportQualifiedPost
HsModule GhcPs
prParsedSource
)
(HsModule GhcPs -> SpanStream
forall a. Data a => a -> SpanStream
mkSpanStream HsModule GhcPs
prParsedSource)
CommentStream
prCommentStream
Anns
prAnns
Bool
prUseRecordDot