1{-# LANGUAGE RecordWildCards #-}
2
3-- | Pretty-printer for Haskell AST.
4module Ormolu.Printer
5  ( printModule,
6  )
7where
8
9import Data.Text (Text)
10import Ormolu.Parser.Result
11import Ormolu.Printer.Combinators
12import Ormolu.Printer.Meat.Module
13import Ormolu.Printer.SpanStream
14import Ormolu.Processing.Postprocess (postprocess)
15
16-- | Render a module.
17printModule ::
18  -- | Result of parsing
19  ParseResult ->
20  -- | Resulting rendition
21  Text
22printModule ParseResult {..} =
23  prLiteralPrefix <> region <> prLiteralSuffix
24  where
25    region =
26      postprocess prIndent $
27        runR
28          ( p_hsModule
29              prStackHeader
30              prShebangs
31              prPragmas
32              prImportQualifiedPost
33              prParsedSource
34          )
35          (mkSpanStream prParsedSource)
36          prCommentStream
37          prAnns
38          prUseRecordDot
39