    -- | Backend for generating highlighted, hyperlinked HTML from Agda sources.

    module Agda.Interaction.Highlighting.HTML.Backend
      ( htmlBackend
      ) where

    import Agda.Interaction.Highlighting.HTML.Base

    import Prelude hiding ((!!), concatMap)

    import Control.DeepSeq
    import Control.Monad.Trans ( MonadIO )
    import Control.Monad.Except ( MonadError(throwError) )

    import Data.Map (Map)

    import GHC.Generics (Generic)

    import Agda.Interaction.Options
        ( ArgDescr(ReqArg, NoArg)
        , OptDescr(..)
        , Flag
        )
    import Agda.Compiler.Backend (Backend(..), Backend'(..), Recompile(..))
    import Agda.Compiler.Common (IsMain(..), curIF)

    import Agda.Syntax.Abstract (ModuleName, toTopLevelModuleName)

    import Agda.TypeChecking.Monad
      ( MonadDebug
      , ReadTCState
      , Definition
      , reportS
      )

    -- | Options for HTML generation

    data HtmlFlags = HtmlFlags
      { HtmlFlags -> Bool
    htmlFlagEnabled              :: Bool
      , HtmlFlags -> FilePath
    htmlFlagDir                  :: FilePath
      , HtmlFlags -> HtmlHighlight
    htmlFlagHighlight            :: HtmlHighlight
      , HtmlFlags -> Bool
    htmlFlagHighlightOccurrences :: Bool
      , HtmlFlags -> Maybe FilePath
    htmlFlagCssFile              :: Maybe FilePath
      } deriving (HtmlFlags -> HtmlFlags -> Bool
    (HtmlFlags -> HtmlFlags -> Bool)
    -> (HtmlFlags -> HtmlFlags -> Bool) -> Eq HtmlFlags
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: HtmlFlags -> HtmlFlags -> Bool
    $c/= :: HtmlFlags -> HtmlFlags -> Bool
    == :: HtmlFlags -> HtmlFlags -> Bool
    $c== :: HtmlFlags -> HtmlFlags -> Bool
    Eq, (forall x. HtmlFlags -> Rep HtmlFlags x)
    -> (forall x. Rep HtmlFlags x -> HtmlFlags) -> Generic HtmlFlags
    forall x. Rep HtmlFlags x -> HtmlFlags
    forall x. HtmlFlags -> Rep HtmlFlags x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep HtmlFlags x -> HtmlFlags
    $cfrom :: forall x. HtmlFlags -> Rep HtmlFlags x
    Generic)

    instance NFData HtmlFlags

    data HtmlCompileEnv = HtmlCompileEnv
      { HtmlCompileEnv -> HtmlOptions
    htmlCompileEnvOpts :: HtmlOptions
      }

    data HtmlModuleEnv = HtmlModuleEnv
      { HtmlModuleEnv -> HtmlCompileEnv
    htmlModEnvCompileEnv :: HtmlCompileEnv
      , HtmlModuleEnv -> ModuleName
    htmlModEnvName       :: ModuleName
      }

    data HtmlModule = HtmlModule
    data HtmlDef = HtmlDef

    htmlBackend :: Backend
    htmlBackend :: Backend
    htmlBackend = Backend' HtmlFlags HtmlCompileEnv HtmlModuleEnv HtmlModule HtmlDef
    -> Backend
    forall opts env menv mod def.
    NFData opts =>
    Backend' opts env menv mod def -> Backend
    Backend Backend' HtmlFlags HtmlCompileEnv HtmlModuleEnv HtmlModule HtmlDef
    htmlBackend'

    htmlBackend' :: Backend' HtmlFlags HtmlCompileEnv HtmlModuleEnv HtmlModule HtmlDef
    htmlBackend' :: Backend' HtmlFlags HtmlCompileEnv HtmlModuleEnv HtmlModule HtmlDef
    htmlBackend' = Backend' :: forall opts env menv mod def.
    FilePath
    -> Maybe FilePath
    -> opts
    -> [OptDescr (Flag opts)]
    -> (opts -> Bool)
    -> (opts -> TCM env)
    -> (env -> IsMain -> Map ModuleName mod -> TCM ())
    -> (env
        -> IsMain
        -> ModuleName
        -> Maybe FilePath
        -> TCM (Recompile menv mod))
    -> (env -> menv -> IsMain -> ModuleName -> [def] -> TCM mod)
    -> (env -> menv -> IsMain -> Definition -> TCM def)
    -> Bool
    -> (QName -> TCM Bool)
    -> Backend' opts env menv mod def
    Backend'
      { backendName :: FilePath
    backendName           = FilePath
    "HTML"
      , backendVersion :: Maybe FilePath
    backendVersion        = Maybe FilePath
    forall a. Maybe a
    Nothing
      , options :: HtmlFlags
    options               = HtmlFlags
    initialHtmlFlags
      , commandLineFlags :: [OptDescr (Flag HtmlFlags)]
    commandLineFlags      = [OptDescr (Flag HtmlFlags)]
    htmlFlags
      , isEnabled :: HtmlFlags -> Bool
    isEnabled             = HtmlFlags -> Bool
    htmlFlagEnabled
      , preCompile :: HtmlFlags -> TCM HtmlCompileEnv
    preCompile            = HtmlFlags -> TCM HtmlCompileEnv
    forall (m :: * -> *).
    (MonadIO m, MonadDebug m) =>
    HtmlFlags -> m HtmlCompileEnv
    preCompileHtml
      , preModule :: HtmlCompileEnv
    -> IsMain
    -> ModuleName
    -> Maybe FilePath
    -> TCM (Recompile HtmlModuleEnv HtmlModule)
    preModule             = HtmlCompileEnv
    -> IsMain
    -> ModuleName
    -> Maybe FilePath
    -> TCM (Recompile HtmlModuleEnv HtmlModule)
    forall (m :: * -> *).
    Applicative m =>
    HtmlCompileEnv
    -> IsMain
    -> ModuleName
    -> Maybe FilePath
    -> m (Recompile HtmlModuleEnv HtmlModule)
    preModuleHtml
      , compileDef :: HtmlCompileEnv
    -> HtmlModuleEnv -> IsMain -> Definition -> TCM HtmlDef
    compileDef            = HtmlCompileEnv
    -> HtmlModuleEnv -> IsMain -> Definition -> TCM HtmlDef
    forall (m :: * -> *).
    Applicative m =>
    HtmlCompileEnv
    -> HtmlModuleEnv -> IsMain -> Definition -> m HtmlDef
    compileDefHtml
      , postModule :: HtmlCompileEnv
    -> HtmlModuleEnv
    -> IsMain
    -> ModuleName
    -> [HtmlDef]
    -> TCM HtmlModule
    postModule            = HtmlCompileEnv
    -> HtmlModuleEnv
    -> IsMain
    -> ModuleName
    -> [HtmlDef]
    -> TCM HtmlModule
    forall (m :: * -> *).
    (MonadIO m, MonadDebug m, ReadTCState m) =>
    HtmlCompileEnv
    -> HtmlModuleEnv
    -> IsMain
    -> ModuleName
    -> [HtmlDef]
    -> m HtmlModule
    postModuleHtml
      , postCompile :: HtmlCompileEnv -> IsMain -> Map ModuleName HtmlModule -> TCM ()
    postCompile           = HtmlCompileEnv -> IsMain -> Map ModuleName HtmlModule -> TCM ()
    forall (m :: * -> *).
    Applicative m =>
    HtmlCompileEnv -> IsMain -> Map ModuleName HtmlModule -> m ()
    postCompileHtml
      -- --only-scope-checking works, but with the caveat that cross-module links
      -- will not have their definition site populated.
      , scopeCheckingSuffices :: Bool
    scopeCheckingSuffices = Bool
    True
      , mayEraseType :: QName -> TCM Bool
    mayEraseType          = TCM Bool -> QName -> TCM Bool
    forall a b. a -> b -> a
    const (TCM Bool -> QName -> TCM Bool) -> TCM Bool -> QName -> TCM Bool
    forall a b. (a -> b) -> a -> b
    $ Bool -> TCM Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    False
      }

    initialHtmlFlags :: HtmlFlags
    initialHtmlFlags :: HtmlFlags
    initialHtmlFlags = HtmlFlags :: Bool
    -> FilePath -> HtmlHighlight -> Bool -> Maybe FilePath -> HtmlFlags
    HtmlFlags
      { htmlFlagEnabled :: Bool
    htmlFlagEnabled   = Bool
    False
      , htmlFlagDir :: FilePath
    htmlFlagDir       = FilePath
    defaultHTMLDir
      , htmlFlagHighlight :: HtmlHighlight
    htmlFlagHighlight = HtmlHighlight
    HighlightAll
      -- Don't enable by default because it causes potential
      -- performance problems
      , htmlFlagHighlightOccurrences :: Bool
    htmlFlagHighlightOccurrences = Bool
    False
      , htmlFlagCssFile :: Maybe FilePath
    htmlFlagCssFile              = Maybe FilePath
    forall a. Maybe a
    Nothing
      }

    htmlOptsOfFlags :: HtmlFlags -> HtmlOptions
    htmlOptsOfFlags :: HtmlFlags -> HtmlOptions
    htmlOptsOfFlags HtmlFlags
    flags = HtmlOptions :: FilePath -> HtmlHighlight -> Bool -> Maybe FilePath -> HtmlOptions
    HtmlOptions
      { htmlOptDir :: FilePath
    htmlOptDir = HtmlFlags -> FilePath
    htmlFlagDir HtmlFlags
    flags
      , htmlOptHighlight :: HtmlHighlight
    htmlOptHighlight = HtmlFlags -> HtmlHighlight
    htmlFlagHighlight HtmlFlags
    flags
      , htmlOptHighlightOccurrences :: Bool
    htmlOptHighlightOccurrences = HtmlFlags -> Bool
    htmlFlagHighlightOccurrences HtmlFlags
    flags
      , htmlOptCssFile :: Maybe FilePath
    htmlOptCssFile = HtmlFlags -> Maybe FilePath
    htmlFlagCssFile HtmlFlags
    flags
      }

    -- | The default output directory for HTML.

    defaultHTMLDir :: FilePath
    defaultHTMLDir :: FilePath
    defaultHTMLDir = FilePath
    "html"

    htmlFlags :: [OptDescr (Flag HtmlFlags)]
    htmlFlags :: [OptDescr (Flag HtmlFlags)]
    htmlFlags =
        [ FilePath
    -> [FilePath]
    -> ArgDescr (Flag HtmlFlags)
    -> FilePath
    -> OptDescr (Flag HtmlFlags)
    forall a.
    FilePath -> [FilePath] -> ArgDescr a -> FilePath -> OptDescr a
    Option []     [FilePath
    "html"] (Flag HtmlFlags -> ArgDescr (Flag HtmlFlags)
    forall a. a -> ArgDescr a
    NoArg Flag HtmlFlags
    htmlFlag)
                        FilePath
    "generate HTML files with highlighted source code"
        , FilePath
    -> [FilePath]
    -> ArgDescr (Flag HtmlFlags)
    -> FilePath
    -> OptDescr (Flag HtmlFlags)
    forall a.
    FilePath -> [FilePath] -> ArgDescr a -> FilePath -> OptDescr a
    Option []     [FilePath
    "html-dir"] ((FilePath -> Flag HtmlFlags)
    -> FilePath -> ArgDescr (Flag HtmlFlags)
    forall a. (FilePath -> a) -> FilePath -> ArgDescr a
    ReqArg FilePath -> Flag HtmlFlags
    htmlDirFlag FilePath
    "DIR")
                        (FilePath
    "directory in which HTML files are placed (default: " FilePath -> FilePath -> FilePath
    forall a. [a] -> [a] -> [a]
    ++
                         FilePath
    defaultHTMLDir FilePath -> FilePath -> FilePath
    forall a. [a] -> [a] -> [a]
    ++ FilePath
    ")")
        , FilePath
    -> [FilePath]
    -> ArgDescr (Flag HtmlFlags)
    -> FilePath
    -> OptDescr (Flag HtmlFlags)
    forall a.
    FilePath -> [FilePath] -> ArgDescr a -> FilePath -> OptDescr a
    Option []     [FilePath
    "highlight-occurrences"] (Flag HtmlFlags -> ArgDescr (Flag HtmlFlags)
    forall a. a -> ArgDescr a
    NoArg Flag HtmlFlags
    highlightOccurrencesFlag)
                        (FilePath
    "highlight all occurrences of hovered symbol in generated " FilePath -> FilePath -> FilePath
    forall a. [a] -> [a] -> [a]
    ++
                         FilePath
    "HTML files")
        , FilePath
    -> [FilePath]
    -> ArgDescr (Flag HtmlFlags)
    -> FilePath
    -> OptDescr (Flag HtmlFlags)
    forall a.
    FilePath -> [FilePath] -> ArgDescr a -> FilePath -> OptDescr a
    Option []     [FilePath
    "css"] ((FilePath -> Flag HtmlFlags)
    -> FilePath -> ArgDescr (Flag HtmlFlags)
    forall a. (FilePath -> a) -> FilePath -> ArgDescr a
    ReqArg FilePath -> Flag HtmlFlags
    cssFlag FilePath
    "URL")
                        FilePath
    "the CSS file used by the HTML files (can be relative)"
        , FilePath
    -> [FilePath]
    -> ArgDescr (Flag HtmlFlags)
    -> FilePath
    -> OptDescr (Flag HtmlFlags)
    forall a.
    FilePath -> [FilePath] -> ArgDescr a -> FilePath -> OptDescr a
    Option []     [FilePath
    "html-highlight"] ((FilePath -> Flag HtmlFlags)
    -> FilePath -> ArgDescr (Flag HtmlFlags)
    forall a. (FilePath -> a) -> FilePath -> ArgDescr a
    ReqArg FilePath -> Flag HtmlFlags
    htmlHighlightFlag FilePath
    "[code,all,auto]")
                        (FilePath
    "whether to highlight only the code parts (code) or " FilePath -> FilePath -> FilePath
    forall a. [a] -> [a] -> [a]
    ++
                         FilePath
    "the file as a whole (all) or " FilePath -> FilePath -> FilePath
    forall a. [a] -> [a] -> [a]
    ++
                         FilePath
    "decide by source file type (auto)")
        ]

    htmlFlag :: Flag HtmlFlags
    htmlFlag :: Flag HtmlFlags
    htmlFlag HtmlFlags
    o = Flag HtmlFlags
    forall (m :: * -> *) a. Monad m => a -> m a
    return Flag HtmlFlags -> Flag HtmlFlags
    forall a b. (a -> b) -> a -> b
    $ HtmlFlags
    o { htmlFlagEnabled :: Bool
    htmlFlagEnabled = Bool
    True }

    htmlDirFlag :: FilePath -> Flag HtmlFlags
    htmlDirFlag :: FilePath -> Flag HtmlFlags
    htmlDirFlag FilePath
    d HtmlFlags
    o = Flag HtmlFlags
    forall (m :: * -> *) a. Monad m => a -> m a
    return Flag HtmlFlags -> Flag HtmlFlags
    forall a b. (a -> b) -> a -> b
    $ HtmlFlags
    o { htmlFlagDir :: FilePath
    htmlFlagDir = FilePath
    d }

    cssFlag :: FilePath -> Flag HtmlFlags
    cssFlag :: FilePath -> Flag HtmlFlags
    cssFlag FilePath
    f HtmlFlags
    o = Flag HtmlFlags
    forall (m :: * -> *) a. Monad m => a -> m a
    return Flag HtmlFlags -> Flag HtmlFlags
    forall a b. (a -> b) -> a -> b
    $ HtmlFlags
    o { htmlFlagCssFile :: Maybe FilePath
    htmlFlagCssFile = FilePath -> Maybe FilePath
    forall a. a -> Maybe a
    Just FilePath
    f }

    highlightOccurrencesFlag :: Flag HtmlFlags
    highlightOccurrencesFlag :: Flag HtmlFlags
    highlightOccurrencesFlag HtmlFlags
    o = Flag HtmlFlags
    forall (m :: * -> *) a. Monad m => a -> m a
    return Flag HtmlFlags -> Flag HtmlFlags
    forall a b. (a -> b) -> a -> b
    $ HtmlFlags
    o { htmlFlagHighlightOccurrences :: Bool
    htmlFlagHighlightOccurrences = Bool
    True }

    parseHtmlHighlightFlag :: MonadError String m => String -> m HtmlHighlight
    parseHtmlHighlightFlag :: forall (m :: * -> *).
    MonadError FilePath m =>
    FilePath -> m HtmlHighlight
    parseHtmlHighlightFlag FilePath
    "code" = HtmlHighlight -> m HtmlHighlight
    forall (m :: * -> *) a. Monad m => a -> m a
    return HtmlHighlight
    HighlightCode
    parseHtmlHighlightFlag FilePath
    "all"  = HtmlHighlight -> m HtmlHighlight
    forall (m :: * -> *) a. Monad m => a -> m a
    return HtmlHighlight
    HighlightAll
    parseHtmlHighlightFlag FilePath
    "auto" = HtmlHighlight -> m HtmlHighlight
    forall (m :: * -> *) a. Monad m => a -> m a
    return HtmlHighlight
    HighlightAuto
    parseHtmlHighlightFlag FilePath
    opt    = FilePath -> m HtmlHighlight
    forall e (m :: * -> *) a. MonadError e m => e -> m a
    throwError (FilePath -> m HtmlHighlight) -> FilePath -> m HtmlHighlight
    forall a b. (a -> b) -> a -> b
    $ [FilePath] -> FilePath
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat [FilePath
    "Invalid option <", FilePath
    opt, FilePath
    ">, expected <all>, <auto> or <code>"]

    htmlHighlightFlag :: String -> Flag HtmlFlags
    htmlHighlightFlag :: FilePath -> Flag HtmlFlags
    htmlHighlightFlag FilePath
    opt    HtmlFlags
    o = do
      HtmlHighlight
    flag <- FilePath -> ExceptT FilePath Identity HtmlHighlight
    forall (m :: * -> *).
    MonadError FilePath m =>
    FilePath -> m HtmlHighlight
    parseHtmlHighlightFlag FilePath
    opt
      Flag HtmlFlags
    forall (m :: * -> *) a. Monad m => a -> m a
    return Flag HtmlFlags -> Flag HtmlFlags
    forall a b. (a -> b) -> a -> b
    $ HtmlFlags
    o { htmlFlagHighlight :: HtmlHighlight
    htmlFlagHighlight = HtmlHighlight
    flag }

    runLogHtmlWithMonadDebug :: MonadDebug m => LogHtmlT m a -> m a
    runLogHtmlWithMonadDebug :: forall (m :: * -> *) a. MonadDebug m => LogHtmlT m a -> m a
    runLogHtmlWithMonadDebug = HtmlLogAction m -> LogHtmlT m a -> m a
    forall (m :: * -> *) a.
    Monad m =>
    HtmlLogAction m -> LogHtmlT m a -> m a
    runLogHtmlWith (HtmlLogAction m -> LogHtmlT m a -> m a)
    -> HtmlLogAction m -> LogHtmlT m a -> m a
    forall a b. (a -> b) -> a -> b
    $ FilePath -> VerboseLevel -> HtmlLogAction m
    forall a (m :: * -> *).
    (ReportS a, MonadDebug m) =>
    FilePath -> VerboseLevel -> a -> m ()
    reportS FilePath
    "html" VerboseLevel
    1

    preCompileHtml
      :: (MonadIO m, MonadDebug m)
      => HtmlFlags
      -> m HtmlCompileEnv
    preCompileHtml :: forall (m :: * -> *).
    (MonadIO m, MonadDebug m) =>
    HtmlFlags -> m HtmlCompileEnv
    preCompileHtml HtmlFlags
    flags = LogHtmlT m HtmlCompileEnv -> m HtmlCompileEnv
    forall (m :: * -> *) a. MonadDebug m => LogHtmlT m a -> m a
    runLogHtmlWithMonadDebug (LogHtmlT m HtmlCompileEnv -> m HtmlCompileEnv)
    -> LogHtmlT m HtmlCompileEnv -> m HtmlCompileEnv
    forall a b. (a -> b) -> a -> b
    $ do
      HtmlLogAction (ReaderT (HtmlLogAction m) m)
    forall (m :: * -> *). MonadLogHtml m => HtmlLogAction m
    logHtml HtmlLogAction (ReaderT (HtmlLogAction m) m)
    -> HtmlLogAction (ReaderT (HtmlLogAction m) m)
    forall a b. (a -> b) -> a -> b
    $ [FilePath] -> FilePath
    unlines
        [ FilePath
    "Warning: HTML is currently generated for ALL files which can be"
        , FilePath
    "reached from the given module, including library files."
        ]
      let opts :: HtmlOptions
    opts = HtmlFlags -> HtmlOptions
    htmlOptsOfFlags HtmlFlags
    flags
      HtmlOptions -> ReaderT (HtmlLogAction m) m ()
    forall (m :: * -> *). MonadIO m => HtmlOptions -> m ()
    prepareCommonDestinationAssets HtmlOptions
    opts
      HtmlCompileEnv -> LogHtmlT m HtmlCompileEnv
    forall (m :: * -> *) a. Monad m => a -> m a
    return (HtmlCompileEnv -> LogHtmlT m HtmlCompileEnv)
    -> HtmlCompileEnv -> LogHtmlT m HtmlCompileEnv
    forall a b. (a -> b) -> a -> b
    $ HtmlOptions -> HtmlCompileEnv
    HtmlCompileEnv HtmlOptions
    opts

    preModuleHtml
      :: Applicative m
      => HtmlCompileEnv
      -> IsMain
      -> ModuleName
      -> Maybe FilePath
      -> m (Recompile HtmlModuleEnv HtmlModule)
    preModuleHtml :: forall (m :: * -> *).
    Applicative m =>
    HtmlCompileEnv
    -> IsMain
    -> ModuleName
    -> Maybe FilePath
    -> m (Recompile HtmlModuleEnv HtmlModule)
    preModuleHtml HtmlCompileEnv
    cenv IsMain
    _isMain ModuleName
    modName Maybe FilePath
    _ifacePath = Recompile HtmlModuleEnv HtmlModule
    -> m (Recompile HtmlModuleEnv HtmlModule)
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Recompile HtmlModuleEnv HtmlModule
     -> m (Recompile HtmlModuleEnv HtmlModule))
    -> Recompile HtmlModuleEnv HtmlModule
    -> m (Recompile HtmlModuleEnv HtmlModule)
    forall a b. (a -> b) -> a -> b
    $ HtmlModuleEnv -> Recompile HtmlModuleEnv HtmlModule
    forall menv mod. menv -> Recompile menv mod
    Recompile (HtmlCompileEnv -> ModuleName -> HtmlModuleEnv
    HtmlModuleEnv HtmlCompileEnv
    cenv ModuleName
    modName)

    compileDefHtml
      :: Applicative m
      => HtmlCompileEnv
      -> HtmlModuleEnv
      -> IsMain
      -> Definition
      -> m HtmlDef
    compileDefHtml :: forall (m :: * -> *).
    Applicative m =>
    HtmlCompileEnv
    -> HtmlModuleEnv -> IsMain -> Definition -> m HtmlDef
    compileDefHtml HtmlCompileEnv
    _env HtmlModuleEnv
    _menv IsMain
    _isMain Definition
    _def = HtmlDef -> m HtmlDef
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure HtmlDef
    HtmlDef

    postModuleHtml
      :: (MonadIO m, MonadDebug m, ReadTCState m)
      => HtmlCompileEnv
      -> HtmlModuleEnv
      -> IsMain
      -> ModuleName
      -> [HtmlDef]
      -> m HtmlModule
    postModuleHtml :: forall (m :: * -> *).
    (MonadIO m, MonadDebug m, ReadTCState m) =>
    HtmlCompileEnv
    -> HtmlModuleEnv
    -> IsMain
    -> ModuleName
    -> [HtmlDef]
    -> m HtmlModule
    postModuleHtml HtmlCompileEnv
    _env HtmlModuleEnv
    menv IsMain
    _isMain ModuleName
    _modName [HtmlDef]
    _defs = do
      let generatePage :: HtmlInputSourceFile -> ReaderT (HtmlLogAction m) m ()
    generatePage = HtmlOptions
    -> HtmlInputSourceFile -> ReaderT (HtmlLogAction m) m ()
    forall (m :: * -> *).
    (MonadIO m, MonadLogHtml m) =>
    HtmlOptions -> HtmlInputSourceFile -> m ()
    defaultPageGen (HtmlOptions
     -> HtmlInputSourceFile -> ReaderT (HtmlLogAction m) m ())
    -> (HtmlModuleEnv -> HtmlOptions)
    -> HtmlModuleEnv
    -> HtmlInputSourceFile
    -> ReaderT (HtmlLogAction m) m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . HtmlCompileEnv -> HtmlOptions
    htmlCompileEnvOpts (HtmlCompileEnv -> HtmlOptions)
    -> (HtmlModuleEnv -> HtmlCompileEnv)
    -> HtmlModuleEnv
    -> HtmlOptions
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . HtmlModuleEnv -> HtmlCompileEnv
    htmlModEnvCompileEnv (HtmlModuleEnv
     -> HtmlInputSourceFile -> ReaderT (HtmlLogAction m) m ())
    -> HtmlModuleEnv
    -> HtmlInputSourceFile
    -> ReaderT (HtmlLogAction m) m ()
    forall a b. (a -> b) -> a -> b
    $ HtmlModuleEnv
    menv
      HtmlInputSourceFile
    htmlSrc <- TopLevelModuleName -> Interface -> HtmlInputSourceFile
    srcFileOfInterface (ModuleName -> TopLevelModuleName
    toTopLevelModuleName (ModuleName -> TopLevelModuleName)
    -> (HtmlModuleEnv -> ModuleName)
    -> HtmlModuleEnv
    -> TopLevelModuleName
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . HtmlModuleEnv -> ModuleName
    htmlModEnvName (HtmlModuleEnv -> TopLevelModuleName)
    -> HtmlModuleEnv -> TopLevelModuleName
    forall a b. (a -> b) -> a -> b
    $ HtmlModuleEnv
    menv) (Interface -> HtmlInputSourceFile)
    -> m Interface -> m HtmlInputSourceFile
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> m Interface
    forall (m :: * -> *). ReadTCState m => m Interface
    curIF
      ReaderT (HtmlLogAction m) m () -> m ()
    forall (m :: * -> *) a. MonadDebug m => LogHtmlT m a -> m a
    runLogHtmlWithMonadDebug (ReaderT (HtmlLogAction m) m () -> m ())
    -> ReaderT (HtmlLogAction m) m () -> m ()
    forall a b. (a -> b) -> a -> b
    $ HtmlInputSourceFile -> ReaderT (HtmlLogAction m) m ()
    generatePage HtmlInputSourceFile
    htmlSrc
      HtmlModule -> m HtmlModule
    forall (m :: * -> *) a. Monad m => a -> m a
    return HtmlModule
    HtmlModule

    postCompileHtml
      :: Applicative m
      => HtmlCompileEnv
      -> IsMain
      -> Map ModuleName HtmlModule
      -> m ()
    postCompileHtml :: forall (m :: * -> *).
    Applicative m =>
    HtmlCompileEnv -> IsMain -> Map ModuleName HtmlModule -> m ()
    postCompileHtml HtmlCompileEnv
    _cenv IsMain
    _isMain Map ModuleName HtmlModule
    _modulesByName = () -> m ()
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure ()