diff options
author | pacien | 2020-06-13 00:06:18 +0200 |
---|---|---|
committer | pacien | 2020-06-13 00:06:18 +0200 |
commit | 00c6216259d8a7b131307953ba5000d2b5dc564b (patch) | |
tree | 14b9f17b13ca811277f349c4457d82547406d78d /compiler/src/Processors.hs | |
parent | 5f7d4fbfc2ec4540d24bc8bf00927c016338c348 (diff) | |
download | ldgallery-00c6216259d8a7b131307953ba5000d2b5dc564b.tar.gz |
compiler: trivial code simplifications
Following HLint's advice.
Diffstat (limited to 'compiler/src/Processors.hs')
-rw-r--r-- | compiler/src/Processors.hs | 15 |
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 | ||
58 | formatFromPath :: Path -> Format | 58 | formatFromPath :: Path -> Format |
59 | formatFromPath = | 59 | formatFromPath = |
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 | ||
98 | copyFileProcessor :: FileProcessor | 95 | copyFileProcessor :: FileProcessor |
99 | copyFileProcessor inputPath outputPath = | 96 | copyFileProcessor 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 | ||
103 | resizePictureUpTo :: Resolution -> FileProcessor | 100 | resizePictureUpTo :: Resolution -> FileProcessor |
104 | resizePictureUpTo maxResolution inputPath outputPath = | 101 | resizePictureUpTo 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 | ||
145 | resourceAt :: FilePath -> Path -> IO Resource | 142 | resourceAt :: FilePath -> Path -> IO Resource |
146 | resourceAt fsPath resPath = getModificationTime fsPath >>= return . Resource resPath | 143 | resourceAt fsPath resPath = Resource resPath <$> getModificationTime fsPath |
147 | 144 | ||
148 | getImageResolution :: FilePath -> IO Resolution | 145 | getImageResolution :: FilePath -> IO Resolution |
149 | getImageResolution fsPath = | 146 | getImageResolution 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 | ||
162 | getPictureProps :: ItemDescriber | 159 | getPictureProps :: ItemDescriber |
163 | getPictureProps fsPath resource = | 160 | getPictureProps fsPath resource = Picture resource <$> getImageResolution fsPath |
164 | getImageResolution fsPath | ||
165 | >>= return . Picture resource | ||
166 | 161 | ||
167 | 162 | ||
168 | type ItemDescriber = | 163 | type ItemDescriber = |