From fd3e5f6986762cc36b2dce44a31379830847e53b Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Wed, 25 Sep 2024 19:45:10 +0200 Subject: [PATCH] De-duplicate code --- byg/src/DependencyGenerator.hs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/byg/src/DependencyGenerator.hs b/byg/src/DependencyGenerator.hs index a376d15..3e954e7 100644 --- a/byg/src/DependencyGenerator.hs +++ b/byg/src/DependencyGenerator.hs @@ -74,6 +74,11 @@ runFunction f input = genDependency (makeDependency input (Function f)) runFunctionIO :: FunctionIO -> Token a -> DepGenM' b runFunctionIO f input = genDependency (makeDependency input (FunctionIO f)) +runFunctionIO' :: FunctionIO -> Token a -> DepGenM () +runFunctionIO' f input = do + _ <- runFunctionIO f input + pure () + mapDepGenM :: (Token a -> DepGenM' b) -> Token [a] -> DepGenM' [b] mapDepGenM f input = genDependencyM $ \target -> do top <- get @@ -114,19 +119,13 @@ readTemplate :: Token FilePath -> DepGenM' Template readTemplate = runFunctionIO ReadTemplate convertImage :: Token ((FilePath, FilePath), ImageConversionSettings) -> DepGenM () -convertImage input = do - _ <- runFunctionIO ConvertImage input - pure () +convertImage = runFunctionIO' ConvertImage saveFile :: Token (String, FilePath) -> DepGenM () -saveFile input = do - _ <- runFunctionIO SaveFile input - pure () +saveFile = runFunctionIO' SaveFile makeDir :: Token FilePath -> DepGenM () -makeDir input = do - _ <- runFunctionIO MakeDir input - pure () +makeDir = runFunctionIO' MakeDir runPandoc :: Token FilePath -> DepGenM' String runPandoc = runFunctionIO RunPandoc