module Main where import Types import ComputationM import Functions handleRecipeDir :: Token Template -> Token FilePath -> ComputationM () handleRecipeDir template dir = do dirContents <- listDirectory dir imageFilenames <- filterComputationM isImageFilename dirContents convertedImageFilenames <- mapComputationM convertedImageFilename imageFilenames flip mapComputationM_ (zipTokens imageFilenames convertedImageFilenames) $ \files -> do settings <- inject $ ResizeToWidth 800 convertImage $ tupleTokens files settings test :: ComputationM () test = do templateFilename <- inject "template.html" template <- readTemplate templateFilename dir <- inject "retter" dirContents <- listDirectory dir mapComputationM_ (handleRecipeDir template) dirContents main :: IO () main = mapM_ print $ evalComputationM test