Browse Source

Незначительные синтаксические правки

master
Maxim Lihachev 9 years ago
parent
commit
b8980ff64b
  1. 15
      audioread.hs

15
audioread.hs

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

Loading…
Cancel
Save