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)
joinPaths :: Token (FilePath, FilePath) -> DepGenM' FilePath
joinPaths = runFunction JoinPaths
joinPaths :: (Token FilePath, Token FilePath) -> DepGenM' FilePath
joinPaths = runFunction JoinPaths . TupleToken
isImageFilename :: Token FilePath -> DepGenM' Bool
isImageFilename = runFunction IsImageFilename
@ -109,8 +109,8 @@ isImageFilename = runFunction IsImageFilename
convertedImageFilename :: Token FilePath -> DepGenM' FilePath
convertedImageFilename = runFunction ConvertedImageFilename
applyTemplate :: Token (Template, String) -> DepGenM' String
applyTemplate = runFunction ApplyTemplate
applyTemplate :: (Token Template, Token String) -> DepGenM' String
applyTemplate = runFunction ApplyTemplate . TupleToken
listDirectory :: Token FilePath -> DepGenM' [FilePath]
listDirectory = runFunctionIO ListDirectory
@ -118,11 +118,11 @@ listDirectory = runFunctionIO ListDirectory
readTemplate :: Token FilePath -> DepGenM' Template
readTemplate = runFunctionIO ReadTemplate
convertImage :: Token ((FilePath, FilePath), ImageConversionSettings) -> DepGenM ()
convertImage = runFunctionIO' ConvertImage
convertImage :: (Token (FilePath, FilePath), Token ImageConversionSettings) -> DepGenM ()
convertImage = runFunctionIO' ConvertImage . TupleToken
saveFile :: Token (String, FilePath) -> DepGenM ()
saveFile = runFunctionIO' SaveFile
saveFile :: (Token String, Token FilePath) -> DepGenM ()
saveFile = runFunctionIO' SaveFile . TupleToken
makeDir :: Token FilePath -> DepGenM ()
makeDir = runFunctionIO' MakeDir

View File

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