{-# LANGUAGE OverloadedStrings #-}
module HumblePrelude.Plugin (plugin) where
import HumblePrelude
import GhcPlugins hiding ((<>))
import HsSyn (hsmodImports, simpleImportDecl)
plugin :: Plugin
plugin = defaultPlugin
{ parsedResultAction = parsedPlugin
, pluginRecompile = flagRecompile }
parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule
parsedPlugin [] ms hpm = parsedPlugin ["HumblePrelude.Extras"] ms hpm
parsedPlugin mods _ pm = do
let rep = noLoc . simpleImportDecl . mkModuleName <$> mods
pure pm { hpm_module = fmap (\m -> m { hsmodImports = rep <> hsmodImports m }) $ hpm_module pm }