diff --git a/audioread.hs b/audioread.hs index aca9eae..9a40f99 100644 --- a/audioread.hs +++ b/audioread.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DeriveDataTypeable, RecordWildCards #-} -- Создан: Ср 28 сен 2016 10:18:53 --- Изменен: Вт 25 окт 2016 15:45:52 +-- Изменен: Пн 07 ноя 2016 09:30:26 -- Copyright (C) 2011-2013, Maxim Lihachev, @@ -55,7 +55,7 @@ notEmpty = (/=) (show "") -- Проверка на действительное ненулевое значение notZero :: RealFloat a => a -> Bool -notZero x = (not $ isNaN x) && (x /= 0) +notZero x = not (isNaN x || x == 0) -- Синтаксический сахар (<@) = map -- a <@ b = map a b @@ -152,18 +152,17 @@ defaultOptions = cmdArgs $ Audioread { -- Вывод строки с префиксом и суффиксом describe :: (Show s) => Int -> String -> s -> String -> IO () -describe o p ms s = let message = show ms in do - when (o == 1) $ putStr $ p - when (notEmpty message) $ putStr message - when (o == 1) $ putStr $ s - putStrLn "" +describe o p m s = putStrLn message where + str = if notEmpty (show s) then show s else "" + message | o == 1 = p ++ str ++ s + | otherwise = str main :: IO () main = do args <- getArgs cmd <- (if null args then withArgs ["--help"] else id) defaultOptions - unless (isInfixOf ".wav" $ file cmd) $ do + unless (".wav" `isInfixOf` file cmd) $ do putStrLn "ERROR: You must specify a correct filename." exitFailure