From 00c6216259d8a7b131307953ba5000d2b5dc564b Mon Sep 17 00:00:00 2001 From: pacien Date: Sat, 13 Jun 2020 00:06:18 +0200 Subject: compiler: trivial code simplifications Following HLint's advice. --- compiler/app/Main.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'compiler/app') diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs index 061fab7..e71e0db 100644 --- a/compiler/app/Main.hs +++ b/compiler/app/Main.hs @@ -21,6 +21,7 @@ module Main where import GHC.Generics (Generic) import Paths_ldgallery_compiler (version, getDataFileName) import Control.Monad (when) +import Data.Functor ((<&>)) import Data.Maybe (isJust) import Data.Version (showVersion) import Data.Aeson (ToJSON) @@ -32,7 +33,7 @@ import Compiler import Files (readDirectory, copyTo, remove) -data ViewerConfig = ViewerConfig +newtype ViewerConfig = ViewerConfig { galleryRoot :: String } deriving (Generic, Show, ToJSON) @@ -92,7 +93,7 @@ options = Options &= help "Deploy either the bundled or the given static web viewer to the output directory" } - &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static web gallery generator with tags") + &= summary ("ldgallery v" ++ showVersion version ++ " - a static web gallery generator with tags") &= program "ldgallery" &= help "Compile a gallery" &= helpArg [explicit, name "h", name "help"] @@ -146,7 +147,7 @@ main = deployViewer :: FilePath -> Options -> IO () deployViewer distPath Options{outputDir, cleanOutput} = - (when cleanOutput $ cleanViewerDir outputDir) + when cleanOutput (cleanViewerDir outputDir) >> copyViewer distPath outputDir >> writeJSON (outputDir "config.json") viewerConfig @@ -154,8 +155,8 @@ main = cleanViewerDir :: FilePath -> IO () cleanViewerDir target = listDirectory target - >>= return . filter (/= gallerySubdir) - >>= mapM_ remove . map (target ) + <&> filter (/= gallerySubdir) + >>= mapM_ (remove . (target )) copyViewer :: FilePath -> FilePath -> IO () copyViewer dist target = -- cgit v1.2.3