Improve ergonomics

This commit is contained in:
Niels G. W. Serup 2024-09-25 19:48:45 +02:00
parent fd3e5f6986
commit ad83c8c941
No known key found for this signature in database
GPG Key ID: 38EEEBCE67324F19
2 changed files with 17 additions and 17 deletions

View File

@ -100,8 +100,8 @@ filterDepGenM f input = do
genDependency (makeDependency (TupleToken (input, conds)) FilterComp) genDependency (makeDependency (TupleToken (input, conds)) FilterComp)
joinPaths :: Token (FilePath, FilePath) -> DepGenM' FilePath joinPaths :: (Token FilePath, Token FilePath) -> DepGenM' FilePath
joinPaths = runFunction JoinPaths joinPaths = runFunction JoinPaths . TupleToken
isImageFilename :: Token FilePath -> DepGenM' Bool isImageFilename :: Token FilePath -> DepGenM' Bool
isImageFilename = runFunction IsImageFilename isImageFilename = runFunction IsImageFilename
@ -109,8 +109,8 @@ isImageFilename = runFunction IsImageFilename
convertedImageFilename :: Token FilePath -> DepGenM' FilePath convertedImageFilename :: Token FilePath -> DepGenM' FilePath
convertedImageFilename = runFunction ConvertedImageFilename convertedImageFilename = runFunction ConvertedImageFilename
applyTemplate :: Token (Template, String) -> DepGenM' String applyTemplate :: (Token Template, Token String) -> DepGenM' String
applyTemplate = runFunction ApplyTemplate applyTemplate = runFunction ApplyTemplate . TupleToken
listDirectory :: Token FilePath -> DepGenM' [FilePath] listDirectory :: Token FilePath -> DepGenM' [FilePath]
listDirectory = runFunctionIO ListDirectory listDirectory = runFunctionIO ListDirectory
@ -118,11 +118,11 @@ listDirectory = runFunctionIO ListDirectory
readTemplate :: Token FilePath -> DepGenM' Template readTemplate :: Token FilePath -> DepGenM' Template
readTemplate = runFunctionIO ReadTemplate readTemplate = runFunctionIO ReadTemplate
convertImage :: Token ((FilePath, FilePath), ImageConversionSettings) -> DepGenM () convertImage :: (Token (FilePath, FilePath), Token ImageConversionSettings) -> DepGenM ()
convertImage = runFunctionIO' ConvertImage convertImage = runFunctionIO' ConvertImage . TupleToken
saveFile :: Token (String, FilePath) -> DepGenM () saveFile :: (Token String, Token FilePath) -> DepGenM ()
saveFile = runFunctionIO' SaveFile saveFile = runFunctionIO' SaveFile . TupleToken
makeDir :: Token FilePath -> DepGenM () makeDir :: Token FilePath -> DepGenM ()
makeDir = runFunctionIO' MakeDir makeDir = runFunctionIO' MakeDir

View File

@ -10,16 +10,16 @@ handleRecipeDir outputDir template dir = do
convertedImageFilenames <- mapDepGenM convertedImageFilename imageFilenames convertedImageFilenames <- mapDepGenM convertedImageFilename imageFilenames
flip mapDepGenM_ (ZipToken (imageFilenames, convertedImageFilenames)) $ \files -> do flip mapDepGenM_ (ZipToken (imageFilenames, convertedImageFilenames)) $ \files -> do
settings <- inject $ ResizeToWidth 800 settings <- inject $ ResizeToWidth 800
convertImage $ TupleToken (files, settings) convertImage (files, settings)
recipeFilenameIn <- inject "ret.md" recipeFilenameIn <- inject "ret.md"
recipePathIn <- joinPaths $ TupleToken (dir, recipeFilenameIn) recipePathIn <- joinPaths (dir, recipeFilenameIn)
recipeDirOut <- joinPaths $ TupleToken (outputDir, dir) recipeDirOut <- joinPaths (outputDir, dir)
makeDir recipeDirOut makeDir recipeDirOut
recipeFilenameOut <- inject "index.html" recipeFilenameOut <- inject "index.html"
recipePathOut <- joinPaths $ TupleToken (recipeDirOut, recipeFilenameOut) recipePathOut <- joinPaths (recipeDirOut, recipeFilenameOut)
htmlBody <- runPandoc recipePathIn htmlBody <- runPandoc recipePathIn
html <- applyTemplate $ TupleToken (template, htmlBody) html <- applyTemplate (template, htmlBody)
saveFile $ TupleToken (html, recipePathOut) saveFile (html, recipePathOut)
generateSite :: DepGenM () generateSite :: DepGenM ()
generateSite = do generateSite = do
@ -33,7 +33,7 @@ generateSite = do
aboutPathIn <- inject "om.md" aboutPathIn <- inject "om.md"
aboutFilenameOut <- inject "om.html" aboutFilenameOut <- inject "om.html"
aboutPathOut <- joinPaths $ TupleToken (outputDir, aboutFilenameOut) aboutPathOut <- joinPaths (outputDir, aboutFilenameOut)
aboutHtmlBody <- runPandoc aboutPathIn aboutHtmlBody <- runPandoc aboutPathIn
aboutHtml <- applyTemplate $ TupleToken (template, aboutHtmlBody) aboutHtml <- applyTemplate (template, aboutHtmlBody)
saveFile $ TupleToken (aboutHtml, aboutPathOut) saveFile (aboutHtml, aboutPathOut)