aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Processors.hs
diff options
context:
space:
mode:
authorpacien2020-06-13 00:06:18 +0200
committerpacien2020-06-13 00:06:18 +0200
commit00c6216259d8a7b131307953ba5000d2b5dc564b (patch)
tree14b9f17b13ca811277f349c4457d82547406d78d /compiler/src/Processors.hs
parent5f7d4fbfc2ec4540d24bc8bf00927c016338c348 (diff)
downloadldgallery-00c6216259d8a7b131307953ba5000d2b5dc564b.tar.gz
compiler: trivial code simplifications
Following HLint's advice.
Diffstat (limited to 'compiler/src/Processors.hs')
-rw-r--r--compiler/src/Processors.hs15
1 files changed, 5 insertions, 10 deletions
diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs
index 0efbf6d..73529ee 100644
--- a/compiler/src/Processors.hs
+++ b/compiler/src/Processors.hs
@@ -57,10 +57,7 @@ data Format =
57 57
58formatFromPath :: Path -> Format 58formatFromPath :: Path -> Format
59formatFromPath = 59formatFromPath =
60 maybe Unknown fromExt 60 maybe Unknown ((fromExt . map toLower) . takeExtension) . fileName
61 . fmap (map toLower)
62 . fmap takeExtension
63 . fileName
64 where 61 where
65 fromExt :: String -> Format 62 fromExt :: String -> Format
66 fromExt ext = case ext of 63 fromExt ext = case ext of
@@ -97,12 +94,12 @@ type FileProcessor =
97 94
98copyFileProcessor :: FileProcessor 95copyFileProcessor :: FileProcessor
99copyFileProcessor inputPath outputPath = 96copyFileProcessor inputPath outputPath =
100 (putStrLn $ "Copying:\t" ++ outputPath) 97 putStrLn ("Copying:\t" ++ outputPath)
101 >> ensureParentDir (flip System.Directory.copyFile) outputPath inputPath 98 >> ensureParentDir (flip System.Directory.copyFile) outputPath inputPath
102 99
103resizePictureUpTo :: Resolution -> FileProcessor 100resizePictureUpTo :: Resolution -> FileProcessor
104resizePictureUpTo maxResolution inputPath outputPath = 101resizePictureUpTo maxResolution inputPath outputPath =
105 (putStrLn $ "Generating:\t" ++ outputPath) 102 putStrLn ("Generating:\t" ++ outputPath)
106 >> ensureParentDir (flip resize) outputPath inputPath 103 >> ensureParentDir (flip resize) outputPath inputPath
107 where 104 where
108 maxSize :: Resolution -> String 105 maxSize :: Resolution -> String
@@ -143,7 +140,7 @@ withCached processor inputPath outputPath =
143 140
144 141
145resourceAt :: FilePath -> Path -> IO Resource 142resourceAt :: FilePath -> Path -> IO Resource
146resourceAt fsPath resPath = getModificationTime fsPath >>= return . Resource resPath 143resourceAt fsPath resPath = Resource resPath <$> getModificationTime fsPath
147 144
148getImageResolution :: FilePath -> IO Resolution 145getImageResolution :: FilePath -> IO Resolution
149getImageResolution fsPath = 146getImageResolution fsPath =
@@ -160,9 +157,7 @@ getImageResolution fsPath =
160 _ -> throwIO $ ProcessingException fsPath "Unable to read image resolution." 157 _ -> throwIO $ ProcessingException fsPath "Unable to read image resolution."
161 158
162getPictureProps :: ItemDescriber 159getPictureProps :: ItemDescriber
163getPictureProps fsPath resource = 160getPictureProps fsPath resource = Picture resource <$> getImageResolution fsPath
164 getImageResolution fsPath
165 >>= return . Picture resource
166 161
167 162
168type ItemDescriber = 163type ItemDescriber =