aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Resource.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/Resource.hs
parent5f7d4fbfc2ec4540d24bc8bf00927c016338c348 (diff)
downloadldgallery-00c6216259d8a7b131307953ba5000d2b5dc564b.tar.gz
compiler: trivial code simplifications
Following HLint's advice.
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r--compiler/src/Resource.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs
index c08677d..607c7f6 100644
--- a/compiler/src/Resource.hs
+++ b/compiler/src/Resource.hs
@@ -29,6 +29,7 @@ import Data.List.Ordered (minusBy)
29import Data.Char (toLower) 29import Data.Char (toLower)
30import Data.Maybe (mapMaybe, fromMaybe) 30import Data.Maybe (mapMaybe, fromMaybe)
31import Data.Function ((&)) 31import Data.Function ((&))
32import Data.Functor ((<&>))
32import qualified Data.Set as Set 33import qualified Data.Set as Set
33import Data.Text (pack) 34import Data.Text (pack)
34import Data.Time.Clock (UTCTime) 35import Data.Time.Clock (UTCTime)
@@ -119,8 +120,8 @@ type ThumbnailProcessor = Path -> IO (Maybe Thumbnail)
119buildGalleryTree :: 120buildGalleryTree ::
120 ItemProcessor -> ThumbnailProcessor -> TagsFromDirectoriesConfig 121 ItemProcessor -> ThumbnailProcessor -> TagsFromDirectoriesConfig
121 -> InputTree -> IO GalleryItem 122 -> InputTree -> IO GalleryItem
122buildGalleryTree processItem processThumbnail tagsFromDirsConfig inputTree = 123buildGalleryTree processItem processThumbnail tagsFromDirsConfig =
123 mkGalleryItem [] inputTree 124 mkGalleryItem []
124 where 125 where
125 mkGalleryItem :: [Tag] -> InputTree -> IO GalleryItem 126 mkGalleryItem :: [Tag] -> InputTree -> IO GalleryItem
126 mkGalleryItem inheritedTags InputFile{path, modTime, sidecar} = 127 mkGalleryItem inheritedTags InputFile{path, modTime, sidecar} =
@@ -190,7 +191,7 @@ flattenGalleryTree simple = [simple]
190 191
191galleryOutputDiff :: GalleryItem -> FSNode -> [Path] 192galleryOutputDiff :: GalleryItem -> FSNode -> [Path]
192galleryOutputDiff resources ref = 193galleryOutputDiff resources ref =
193 (filesystemPaths ref) \\ (compiledPaths $ flattenGalleryTree resources) 194 filesystemPaths ref \\ compiledPaths (flattenGalleryTree resources)
194 where 195 where
195 filesystemPaths :: FSNode -> [Path] 196 filesystemPaths :: FSNode -> [Path]
196 filesystemPaths = map Files.path . tail . flattenDir 197 filesystemPaths = map Files.path . tail . flattenDir
@@ -212,8 +213,7 @@ galleryOutputDiff resources ref =
212 213
213 thumbnailPaths :: [GalleryItem] -> [Path] 214 thumbnailPaths :: [GalleryItem] -> [Path]
214 thumbnailPaths = 215 thumbnailPaths =
215 map resourcePath 216 map (resourcePath . (resource :: (Thumbnail -> Resource)))
216 . map (resource :: (Thumbnail -> Resource))
217 . mapMaybe thumbnail 217 . mapMaybe thumbnail
218 218
219 (\\) :: [Path] -> [Path] -> [Path] 219 (\\) :: [Path] -> [Path] -> [Path]
@@ -235,7 +235,7 @@ galleryOutputDiff resources ref =
235galleryCleanupResourceDir :: GalleryItem -> FileName -> IO () 235galleryCleanupResourceDir :: GalleryItem -> FileName -> IO ()
236galleryCleanupResourceDir resourceTree outputDir = 236galleryCleanupResourceDir resourceTree outputDir =
237 readDirectory outputDir 237 readDirectory outputDir
238 >>= return . galleryOutputDiff resourceTree . root 238 <&> galleryOutputDiff resourceTree . root
239 >>= return . sortOn ((0 -) . pathLength) -- nested files before their parent dirs 239 <&> sortOn ((0 -) . pathLength) -- nested files before their parent dirs
240 >>= return . map (localPath . (/>) outputDir) 240 <&> map (localPath . (/>) outputDir)
241 >>= mapM_ remove 241 >>= mapM_ remove