From b8980ff64bc96823f6644df5a509ad667fd0629b Mon Sep 17 00:00:00 2001 From: Maxim Lihachev Date: Mon, 7 Nov 2016 09:31:00 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B7=D0=BD=D0=B0=D1=87=D0=B8?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D1=81=D0=B8=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=D0=BA=D1=81=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- audioread.hs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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