Skip to content

Commit

Permalink
[#82] Fix compile error under GHC 9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
vaclavsvejcar committed Dec 16, 2021
1 parent f2f6578 commit d51ee77
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion doctest/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module Main (main) where
import Test.DocTest

main :: IO ()
main = doctest ["-XOverloadedStrings", "src"]
main = doctest ["-XOverloadedStrings", "-XTemplateHaskell", "src"]
80 changes: 40 additions & 40 deletions src/Headroom/PostProcess.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,46 +65,6 @@ suffixLenses ''UpdateCopyrightConfig
suffixLensesFor ["ppcConfig"] ''PostProcessConfig


-- | Runs the /post-processing function/ using the given /environment/ and text
-- of rendered /license header/ as input.
postProcess :: PostProcess env
-- ^ /post-processor/ to run
-> env
-- ^ environment value
-> Text
-- ^ text of rendered /license header/
-> Text
-- ^ processed text of /license header/
postProcess (PostProcess fn) env input = runReader (fn input) env


-- | Composition of various /post-processors/, which environment is
-- based on /YAML/ configuration and which can be enabled/disabled to fit
-- end user's needs.
configuredPostProcess :: (Has CurrentYear env, Has UpdateCopyrightMode env)
=> CtPostProcessConfigs
-- ^ configuration of /post-processors/
-> PostProcess env
-- ^ composed /post-processor/
configuredPostProcess PostProcessConfigs {..} = mconcat
[ifEnabled ppcsUpdateCopyright updateCopyright]
where
ifEnabled PostProcessConfig {..} fn | ppcEnabled = fn
| otherwise = mempty


-- | Takes already rendered /license header/ and post-process it based on the
-- given configuration.
postProcessHeader :: ConfiguredEnv
-- ^ configuration used to define post-processing behaviour
-> Text
-- ^ rendered text of /license header/
-> Text
-- ^ post-processed text of /license header/
postProcessHeader env =
postProcess (configuredPostProcess (cePostProcessConfigs env)) env


-- | Environemnt data type for the composed /post-processor/
-- ('configuredPostProcess').
data ConfiguredEnv = ConfiguredEnv
Expand Down Expand Up @@ -150,6 +110,46 @@ mkConfiguredEnv ceCurrentYear vars configs = do
(configs' ^. authorsL)


-- | Runs the /post-processing function/ using the given /environment/ and text
-- of rendered /license header/ as input.
postProcess :: PostProcess env
-- ^ /post-processor/ to run
-> env
-- ^ environment value
-> Text
-- ^ text of rendered /license header/
-> Text
-- ^ processed text of /license header/
postProcess (PostProcess fn) env input = runReader (fn input) env


-- | Composition of various /post-processors/, which environment is
-- based on /YAML/ configuration and which can be enabled/disabled to fit
-- end user's needs.
configuredPostProcess :: (Has CurrentYear env, Has UpdateCopyrightMode env)
=> CtPostProcessConfigs
-- ^ configuration of /post-processors/
-> PostProcess env
-- ^ composed /post-processor/
configuredPostProcess PostProcessConfigs {..} = mconcat
[ifEnabled ppcsUpdateCopyright updateCopyright]
where
ifEnabled PostProcessConfig {..} fn | ppcEnabled = fn
| otherwise = mempty


-- | Takes already rendered /license header/ and post-process it based on the
-- given configuration.
postProcessHeader :: ConfiguredEnv
-- ^ configuration used to define post-processing behaviour
-> Text
-- ^ rendered text of /license header/
-> Text
-- ^ post-processed text of /license header/
postProcessHeader env =
postProcess (configuredPostProcess (cePostProcessConfigs env)) env


------------------------------ PRIVATE FUNCTIONS -----------------------------

compileTemplates :: forall a m
Expand Down

0 comments on commit d51ee77

Please sign in to comment.