cln: hlint: Remove unless and $> warnings.

This commit is contained in:
Stephen Morgan 2021-08-16 14:57:15 +10:00 committed by Simon Michael
parent beecb3c9ac
commit 21e62ffcbd
7 changed files with 10 additions and 10 deletions

View File

@ -13,8 +13,6 @@
- ignore: {name: "Redundant bracket"}
- ignore: {name: "Avoid reverse"}
- ignore: {name: "Eta reduce"}
- ignore: {name: "Use $>"}
- ignore: {name: "Use unless"}
- ignore: {name: "Use =<<"}
- ignore: {name: "Use fmap"}
- ignore: {name: "Use <&>"}

View File

@ -102,6 +102,7 @@ import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.State.Strict (runStateT)
import Data.String (fromString)
import Data.Function (on)
import Data.Functor (($>))
import Data.Functor.Identity (Identity(..))
import Data.List (foldl', groupBy, intercalate, nub, sortOn)
import Data.List.NonEmpty (NonEmpty(..), nonEmpty, toList)
@ -493,5 +494,5 @@ sameish f = (==) `on` f . toGregorian . H.postingDate
-- | Helper for 'Compare' and 'Connect' parsers.
gostringsp :: Monad m => [(String, a)] -> H.TextParser m a
gostringsp ((s,a):rest) = P.try (P.string (fromString s) *> pure a) `mplus` gostringsp rest
gostringsp ((s,a):rest) = P.try (P.string (fromString s) $> a) `mplus` gostringsp rest
gostringsp [] = mzero

View File

@ -30,6 +30,6 @@ main = withJournalDo defcliopts $ \j -> do
]
forM_ filetags $ \(t,f) -> do
exists <- doesFileExist f
when (not exists) $ do
unless exists $ do
putStrLn $ "file not found in tag: " ++ t ++ ": " ++ f
exitFailure

View File

@ -31,6 +31,6 @@ main = withJournalDo defcliopts $ \j -> do
]
forM_ filetags $ \(t,f) -> do
exists <- doesFileExist f
when (not exists) $ do
unless exists $ do
putStrLn $ "file not found in tag: " ++ t ++ ": " ++ f
exitFailure

View File

@ -89,6 +89,7 @@ import Data.Char (digitToInt, isDigit, ord)
import Data.Default
import Data.Foldable (asum)
import Data.Function (on)
import Data.Functor (($>))
import Data.Maybe
import qualified Data.Set as Set
import Data.Text (Text)
@ -776,7 +777,7 @@ validMonth n = n >= 1 && n <= 12
validDay n = n >= 1 && n <= 31
failIfInvalidDate :: Fail.MonadFail m => SmartDate -> m SmartDate
failIfInvalidDate s = unless isValid (Fail.fail $ "bad smart date: " ++ show s) *> return s
failIfInvalidDate s = unless isValid (Fail.fail $ "bad smart date: " ++ show s) $> s
where isValid = case s of
SmartAssumeStart y (Just (m, md)) -> isJust $ fromGregorianValid y m (fromMaybe 1 md)
SmartFromReference mm d -> isJust $ fromGregorianValid 2004 (fromMaybe 1 mm) d

View File

@ -1013,7 +1013,7 @@ checkBalanceAssertionOneCommodityB p@Posting{paccount=assertedacct} assertedamt
-- (showAmount assertedamt)
(show $ aquantity assertedamt - aquantity actualbalincomm)
when (not pass) $ throwError errmsg
unless pass $ throwError errmsg
-- | Throw an error if this posting is trying to do an illegal balance assignment.
checkIllegalBalanceAssignmentB :: Posting -> Balancing s ()

View File

@ -46,7 +46,7 @@ module Hledger.Read (
--- ** imports
import Control.Arrow (right)
import qualified Control.Exception as C
import Control.Monad (when)
import Control.Monad (unless, when)
import "mtl" Control.Monad.Except (runExceptT)
import Data.Default (def)
import Data.Foldable (asum)
@ -192,7 +192,7 @@ requireJournalFileExists :: FilePath -> IO ()
requireJournalFileExists "-" = return ()
requireJournalFileExists f = do
exists <- doesFileExist f
when (not exists) $ do -- XXX might not be a journal file
unless exists $ do -- XXX might not be a journal file
hPutStr stderr $ "The hledger journal file \"" <> f <> "\" was not found.\n"
hPutStr stderr "Please create it first, eg with \"hledger add\" or a text editor.\n"
hPutStr stderr "Or, specify an existing journal file with -f or LEDGER_FILE.\n"
@ -207,7 +207,7 @@ ensureJournalFileExists f = do
hPutStr stderr $ "Part of file path \"" <> show f <> "\"\n ends with a dot, which is unsafe on Windows; please use a different path.\n"
exitFailure
exists <- doesFileExist f
when (not exists) $ do
unless exists $ do
hPutStr stderr $ "Creating hledger journal file " <> show f <> ".\n"
-- note Hledger.Utils.UTF8.* do no line ending conversion on windows,
-- we currently require unix line endings on all platforms.