1{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE RecordWildCards #-}
4-- | Rendering of modules.
6module Ormolu.Printer.Meat.Module
12import Data.Maybe (isJust)
16import Ormolu.Printer.Combinators
17import Ormolu.Printer.Comments
18import Ormolu.Printer.Meat.Common
19import Ormolu.Printer.Meat.Declaration
20import Ormolu.Printer.Meat.Declaration.Warning
21import Ormolu.Printer.Meat.ImportExport
22import Ormolu.Printer.Meat.LanguagePragma
23import SrcLoc (combineSrcSpans)
25p_hsModule :: Set String -> ParsedSource -> R ()
26p_hsModule exts loc@(L moduleSpan hsModule) = do
27 -- NOTE If span of exports in multiline, the whole thing is multiline.
28 -- This is especially important because span of module itself always seems
29 -- to have length zero, so it's not reliable for layout selection.
31 case hsmodExports hsModule of
33 Just (L exportsSpan _) -> combineSrcSpans moduleSpan exportsSpan
34 locatedVia (Just spn) loc $ \HsModule {..} -> do
35 let hasLangPragmas = not (null exts)
36 hasModuleHeader = isJust hsmodName
37 hasImports = not (null hsmodImports)
38 hasDecls = not (null hsmodDecls)
40 when (hasLangPragmas &&
41 (hasModuleHeader || hasImports || hasDecls)) $
45 Just hsmodName' -> line $ do
46 located hsmodName' p_hsmodName
47 forM_ hsmodDeprecMessage (located' p_moduleWarning)
50 Just hsmodExports' -> do
52 inci (locatedVia Nothing hsmodExports' p_hsmodExports)
55 when (hasImports || hasDecls) newline
56 forM_ (sortImports hsmodImports) (located' p_hsmodImport)
57 when (hasImports && hasDecls) newline
58 p_hsDecls Free hsmodDecls
59 trailingComments <- hasMoreComments
60 when (trailingComments && hasModuleHeader) newline
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list