Require simpler IsImageExtension
This commit is contained in:
parent
056c8d278b
commit
c22fd7ddf0
|
@ -15,7 +15,7 @@ module DependencyGenerator
|
|||
|
||||
, joinPaths
|
||||
, fileComponents
|
||||
, isImageFilename
|
||||
, isImageExtension
|
||||
, convertedImageFilename
|
||||
, applyTemplate
|
||||
, listDirectory
|
||||
|
@ -97,10 +97,9 @@ mapDepGenM_ f input = do
|
|||
_ <- mapDepGenM (\x -> f x >> pure NoToken) input
|
||||
pure ()
|
||||
|
||||
filterDepGenM :: (Token a -> DepGenM' Bool) -> Token [a] -> DepGenM' [a]
|
||||
filterDepGenM f input = do
|
||||
conds <- mapDepGenM f input
|
||||
genDependency (makeDependency (TupleToken (input, conds)) FilterComp)
|
||||
filterDepGenM :: Token [Bool] -> Token [a] -> DepGenM' [a]
|
||||
filterDepGenM mask input = do
|
||||
genDependency (makeDependency (TupleToken (input, mask)) FilterComp)
|
||||
|
||||
unzipFstDepGenM :: TokenableTo [(a, b)] t => t -> DepGenM (Token [a])
|
||||
unzipFstDepGenM t = do
|
||||
|
@ -141,8 +140,8 @@ joinPaths (a, b) = do
|
|||
fileComponents :: TokenableTo FilePath a => a -> DepGenM' (String, String)
|
||||
fileComponents a = runFunction FileComponents =<< toToken a
|
||||
|
||||
isImageFilename :: TokenableTo FilePath a => a -> DepGenM' Bool
|
||||
isImageFilename a = runFunction IsImageFilename =<< toToken a
|
||||
isImageExtension :: TokenableTo FilePath a => a -> DepGenM' Bool
|
||||
isImageExtension a = runFunction IsImageExtension =<< toToken a
|
||||
|
||||
convertedImageFilename :: TokenableTo FilePath a => a -> DepGenM' FilePath
|
||||
convertedImageFilename a = runFunction ConvertedImageFilename =<< toToken a
|
||||
|
|
|
@ -9,7 +9,7 @@ evalFunction f x = case (f, x) of
|
|||
(JoinPaths, Tuple (String _, String _)) ->
|
||||
String undefined
|
||||
|
||||
(IsImageFilename, String _) ->
|
||||
(IsImageExtension, String _) ->
|
||||
Bool undefined
|
||||
|
||||
(ConvertedImageFilename, String _) ->
|
||||
|
|
|
@ -7,7 +7,8 @@ handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> DepGenM
|
|||
handleRecipeDir outputDir template dir = do
|
||||
dirContents <- listDirectory dir
|
||||
(bases, exts) <- unzipDepGenM (mapDepGenM fileComponents dirContents)
|
||||
imageFilenames <- filterDepGenM isImageFilename dirContents
|
||||
areImageFilenames <- mapDepGenM isImageExtension exts
|
||||
imageFilenames <- filterDepGenM areImageFilenames dirContents
|
||||
convertedImageFilenames <- mapDepGenM convertedImageFilename imageFilenames
|
||||
mapDepGenM_
|
||||
(\files -> convertImage (files, inject $ ResizeToWidth 800))
|
||||
|
|
|
@ -6,7 +6,7 @@ import Language.Haskell.TH.Syntax (Lift)
|
|||
|
||||
data Function = JoinPaths
|
||||
| FileComponents
|
||||
| IsImageFilename
|
||||
| IsImageExtension
|
||||
| ConvertedImageFilename
|
||||
| ApplyTemplate
|
||||
deriving (Show, Lift)
|
||||
|
|
Loading…
Reference in New Issue