cln: hlint: Remove unless and $> warnings.
This commit is contained in:
		
							parent
							
								
									beecb3c9ac
								
							
						
					
					
						commit
						21e62ffcbd
					
				| @ -13,8 +13,6 @@ | |||||||
| - ignore: {name: "Redundant bracket"} | - ignore: {name: "Redundant bracket"} | ||||||
| - ignore: {name: "Avoid reverse"} | - ignore: {name: "Avoid reverse"} | ||||||
| - ignore: {name: "Eta reduce"} | - ignore: {name: "Eta reduce"} | ||||||
| - ignore: {name: "Use $>"} |  | ||||||
| - ignore: {name: "Use unless"} |  | ||||||
| - ignore: {name: "Use =<<"} | - ignore: {name: "Use =<<"} | ||||||
| - ignore: {name: "Use fmap"} | - ignore: {name: "Use fmap"} | ||||||
| - ignore: {name: "Use <&>"} | - ignore: {name: "Use <&>"} | ||||||
|  | |||||||
| @ -102,6 +102,7 @@ import Control.Monad.Trans.Class (lift) | |||||||
| import Control.Monad.Trans.State.Strict (runStateT) | import Control.Monad.Trans.State.Strict (runStateT) | ||||||
| import Data.String (fromString) | import Data.String (fromString) | ||||||
| import Data.Function (on) | import Data.Function (on) | ||||||
|  | import Data.Functor (($>)) | ||||||
| import Data.Functor.Identity (Identity(..)) | import Data.Functor.Identity (Identity(..)) | ||||||
| import Data.List (foldl', groupBy, intercalate, nub, sortOn) | import Data.List (foldl', groupBy, intercalate, nub, sortOn) | ||||||
| import Data.List.NonEmpty (NonEmpty(..), nonEmpty, toList) | import Data.List.NonEmpty (NonEmpty(..), nonEmpty, toList) | ||||||
| @ -493,5 +494,5 @@ sameish f = (==) `on` f . toGregorian . H.postingDate | |||||||
| 
 | 
 | ||||||
| -- | Helper for 'Compare' and 'Connect' parsers. | -- | Helper for 'Compare' and 'Connect' parsers. | ||||||
| gostringsp :: Monad m => [(String, a)] -> H.TextParser m a | 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 | gostringsp [] = mzero | ||||||
|  | |||||||
| @ -30,6 +30,6 @@ main = withJournalDo defcliopts $ \j -> do | |||||||
|                  ] |                  ] | ||||||
|   forM_ filetags $ \(t,f) -> do |   forM_ filetags $ \(t,f) -> do | ||||||
|     exists <- doesFileExist f |     exists <- doesFileExist f | ||||||
|     when (not exists) $ do |     unless exists $ do | ||||||
|       putStrLn $ "file not found in tag: " ++ t ++ ": " ++ f |       putStrLn $ "file not found in tag: " ++ t ++ ": " ++ f | ||||||
|       exitFailure |       exitFailure | ||||||
|  | |||||||
| @ -31,6 +31,6 @@ main = withJournalDo defcliopts $ \j -> do | |||||||
|                  ] |                  ] | ||||||
|   forM_ filetags $ \(t,f) -> do |   forM_ filetags $ \(t,f) -> do | ||||||
|     exists <- doesFileExist f |     exists <- doesFileExist f | ||||||
|     when (not exists) $ do |     unless exists $ do | ||||||
|       putStrLn $ "file not found in tag: " ++ t ++ ": " ++ f |       putStrLn $ "file not found in tag: " ++ t ++ ": " ++ f | ||||||
|       exitFailure |       exitFailure | ||||||
|  | |||||||
| @ -89,6 +89,7 @@ import Data.Char (digitToInt, isDigit, ord) | |||||||
| import Data.Default | import Data.Default | ||||||
| import Data.Foldable (asum) | import Data.Foldable (asum) | ||||||
| import Data.Function (on) | import Data.Function (on) | ||||||
|  | import Data.Functor (($>)) | ||||||
| import Data.Maybe | import Data.Maybe | ||||||
| import qualified Data.Set as Set | import qualified Data.Set as Set | ||||||
| import Data.Text (Text) | import Data.Text (Text) | ||||||
| @ -776,7 +777,7 @@ validMonth n = n >= 1 && n <= 12 | |||||||
| validDay n = n >= 1 && n <= 31 | validDay n = n >= 1 && n <= 31 | ||||||
| 
 | 
 | ||||||
| failIfInvalidDate :: Fail.MonadFail m => SmartDate -> m SmartDate | 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 |   where isValid = case s of | ||||||
|             SmartAssumeStart y (Just (m, md)) -> isJust $ fromGregorianValid y m (fromMaybe 1 md) |             SmartAssumeStart y (Just (m, md)) -> isJust $ fromGregorianValid y m (fromMaybe 1 md) | ||||||
|             SmartFromReference mm d           -> isJust $ fromGregorianValid 2004 (fromMaybe 1 mm) d |             SmartFromReference mm d           -> isJust $ fromGregorianValid 2004 (fromMaybe 1 mm) d | ||||||
|  | |||||||
| @ -1013,7 +1013,7 @@ checkBalanceAssertionOneCommodityB p@Posting{paccount=assertedacct} assertedamt | |||||||
|       -- (showAmount assertedamt) |       -- (showAmount assertedamt) | ||||||
|       (show $ aquantity assertedamt - aquantity actualbalincomm) |       (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. | -- | Throw an error if this posting is trying to do an illegal balance assignment. | ||||||
| checkIllegalBalanceAssignmentB :: Posting -> Balancing s () | checkIllegalBalanceAssignmentB :: Posting -> Balancing s () | ||||||
|  | |||||||
| @ -46,7 +46,7 @@ module Hledger.Read ( | |||||||
| --- ** imports | --- ** imports | ||||||
| import Control.Arrow (right) | import Control.Arrow (right) | ||||||
| import qualified Control.Exception as C | import qualified Control.Exception as C | ||||||
| import Control.Monad (when) | import Control.Monad (unless, when) | ||||||
| import "mtl" Control.Monad.Except (runExceptT) | import "mtl" Control.Monad.Except (runExceptT) | ||||||
| import Data.Default (def) | import Data.Default (def) | ||||||
| import Data.Foldable (asum) | import Data.Foldable (asum) | ||||||
| @ -192,7 +192,7 @@ requireJournalFileExists :: FilePath -> IO () | |||||||
| requireJournalFileExists "-" = return () | requireJournalFileExists "-" = return () | ||||||
| requireJournalFileExists f = do | requireJournalFileExists f = do | ||||||
|   exists <- doesFileExist f |   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 $ "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 "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" |     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" |     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 |     exitFailure | ||||||
|   exists <- doesFileExist f |   exists <- doesFileExist f | ||||||
|   when (not exists) $ do |   unless exists $ do | ||||||
|     hPutStr stderr $ "Creating hledger journal file " <> show f <> ".\n" |     hPutStr stderr $ "Creating hledger journal file " <> show f <> ".\n" | ||||||
|     -- note Hledger.Utils.UTF8.* do no line ending conversion on windows, |     -- note Hledger.Utils.UTF8.* do no line ending conversion on windows, | ||||||
|     -- we currently require unix line endings on all platforms. |     -- we currently require unix line endings on all platforms. | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user