Solve hlint comments

This commit is contained in:
Juan Paucar 2019-07-26 17:57:17 -05:00
parent f9bea43290
commit e7a2d4d0b7
4 changed files with 12 additions and 13 deletions

View File

@ -7,7 +7,7 @@ where
import Control.Monad
import Control.Monad.Reader
import Data.List (isPrefixOf)
import Data.Maybe (catMaybes)
import Data.Maybe (mapMaybe)
import Numeric.Natural
import Path
import Path.IO
@ -143,7 +143,7 @@ spec = do
describe "playScriptLocally (successful run)" $
it "check that local scripts are run and deployment is successful" $ \(deployPath, repoPath) -> runHap $ do
let localCommands = catMaybes $ map Hap.mkGenericCommand ["pwd", "ls"]
let localCommands = mapMaybe Hap.mkGenericCommand ["pwd", "ls"]
task = mkTask deployPath repoPath
Hap.playScriptLocally localCommands
release <- Hap.pushRelease task
@ -152,7 +152,7 @@ spec = do
describe "playScriptLocally (error exit)" $
it "check that deployment isn't done" $ \(deployPath, repoPath) -> (runHap $ do
let localCommands = catMaybes $ map Hap.mkGenericCommand ["pwd", "ls", "false"]
let localCommands = mapMaybe Hap.mkGenericCommand ["pwd", "ls", "false"]
task = mkTask deployPath repoPath
Hap.playScriptLocally localCommands
release <- Hap.pushRelease task

View File

@ -35,9 +35,9 @@ where
import Control.Monad
import Control.Monad.Except
import Control.Monad.Reader (local)
import Data.List (dropWhileEnd, genericDrop, sortBy)
import Data.List (dropWhileEnd, genericDrop, sortOn)
import Data.Maybe (mapMaybe)
import Data.Ord (Down (..), comparing)
import Data.Ord (Down (..))
import Data.Time
import Numeric.Natural
import Path
@ -219,7 +219,7 @@ deployedReleases deployPath = do
let rpath = releasesPath deployPath
xs <- exec (Find 1 rpath :: Find Dir)
ps <- stripDirs rpath (filter (/= rpath) xs)
(return . sortBy (comparing Down) . mapMaybe parseRelease)
(return . sortOn Down . mapMaybe parseRelease)
(dropWhileEnd (== '/') . fromRelDir <$> ps)
-- | Return a list of successfully completed releases sorted newest first.
@ -231,7 +231,7 @@ completedReleases deployPath = do
let cpath = ctokensPath deployPath
xs <- exec (Find 1 cpath :: Find File)
ps <- stripDirs cpath xs
(return . sortBy (comparing Down) . mapMaybe parseRelease)
(return . sortOn Down . mapMaybe parseRelease)
(dropWhileEnd (== '/') . fromRelFile <$> ps)
----------------------------------------------------------------------------

View File

@ -288,7 +288,7 @@ unGenericCommand (GenericCommand x) = x
-- | Read commands from a file.
readScript :: MonadIO m => Path Abs File -> m [GenericCommand]
readScript path = liftIO $ catMaybes . fmap mkGenericCommand . lines
readScript path = liftIO $ mapMaybe mkGenericCommand . lines
<$> readFile (fromAbsFile path)
----------------------------------------------------------------------------

View File

@ -10,6 +10,7 @@
-- Type definitions for the Hapistrano tool.
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE LambdaCase #-}
module System.Hapistrano.Types
( Hapistrano
@ -79,8 +80,7 @@ data ReleaseFormat
deriving (Show, Read, Eq, Ord, Enum, Bounded)
instance FromJSON ReleaseFormat where
parseJSON = withText "release format" $ \t ->
case t of
parseJSON = withText "release format" $ \case
"short" -> return ReleaseShort
"long" -> return ReleaseLong
_ -> fail "expected 'short' or 'long'"
@ -92,11 +92,10 @@ data Shell =
deriving (Show, Eq, Ord)
instance FromJSON Shell where
parseJSON = withText "shell" $ \t ->
case t of
parseJSON = withText "shell" $ \case
"bash" -> return Bash
"zsh" -> return Zsh
_ -> fail "supported shells: 'bash' or 'zsh'"
_ -> fail "supported shells: 'bash' or 'zsh'"
-- | SSH options.