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