elmModule :: IParser Module.Module
elmModule =
  do  preModule <- option [] freshLine
      h <- moduleDecl
      preDocsComments <- option [] freshLine
      (docs, postDocsComments) <-
        choice
          [ (,) <$> addLocation (Just <$> docCommentAsMarkdown) <*> freshLine
          , (,) <$> addLocation (return Nothing) <*> return []
          ]
      (preImportComments, imports', postImportComments) <- imports
      decls <- declarations
      trailingComments <-
          (++)
              <$> option [] freshLine
              <*> option [] spaces
      eof

      return $
        Module.Module
          preModule
          h
          docs
          (preDocsComments ++ postDocsComments ++ preImportComments, imports')
          ((map AST.Declaration.BodyComment postImportComments) ++ decls ++ (map AST.Declaration.BodyComment trailingComments))
elmModule :: IParser Module.Module
elmModule =
  do  preModule <- option [] freshLine
      h <- moduleDecl
      preDocsComments <- option [] freshLine
      (docs, postDocsComments) <-
        choice
          [ (,) <$> addLocation (Just <$> docCommentAsMarkdown) <*> freshLine
          , (,) <$> addLocation (return Nothing) <*> return []
          ]
      (preImportComments, imports', postImportComments) <- imports
      decls <- declarations
      trailingComments <-
          (++)
              <$> option [] freshLine
              <*> option [] spaces
      eof

      return $
        Module.Module
          preModule
          h
          docs
          (preDocsComments ++ postDocsComments ++ preImportComments, imports')
          ((map AST.Declaration.BodyComment postImportComments) ++ decls ++ (map AST.Declaration.BodyComment trailingComments))
elmModule =
  do  preModule <- option [] freshLine
      h <- moduleDecl
      preDocsComments <- option [] freshLine
      (docs, postDocsComments) <-
        choice
          [ (,) <$> addLocation (Just <$> docCommentAsMarkdown) <*> freshLine
          , (,) <$> addLocation (return Nothing) <*> return []
          ]
      (preImportComments, imports', postImportComments) <- imports
      decls <- declarations
      trailingComments <-
          (++)
              <$> option [] freshLine
              <*> option [] spaces
      eof

      return $
        Module.Module
          preModule
          h
          docs
          (preDocsComments ++ postDocsComments ++ preImportComments, imports')
          ((map AST.Declaration.BodyComment postImportComments) ++ decls ++ (map AST.Declaration.BodyComment trailingComments))