1. nakamura
  2. udon

Commits

nakamura  committed cc0b387

use tuple instead of list

  • Participants
  • Parent commits b3cecc7
  • Branches default
  • Tags 0.1

Comments (0)

Files changed (1)

File src/Client.hs

View file
 module Client where
 
 import Prelude hiding (catch)
-import Control.Arrow ((>>>), (&&&), second, (***))
+import Control.Arrow ((>>>), (&&&), (***))
 import Control.Monad (forM_)
 import Control.Monad.Reader (ReaderT, runReaderT, ask, asks, MonadReader, MonadIO)
 import Data.List (intercalate, mapAccumL)
 
 showSeconds :: Integer -> String
 showSeconds sec
-    | [0, h, m, s] <- secToDHMS sec = printf "%02d:%02d:%02d" h m s
-    | [1, h, m, s] <- secToDHMS sec = printf "1 day %02d:%02d" h m
-    | [d, h, m, s] <- secToDHMS sec = printf "%d days %02d:%02d" d h m
+    | (0, h, m, s) <- secToDHMS sec = printf "%02d:%02d:%02d" h m s
+    | (1, h, m, s) <- secToDHMS sec = printf "1 day %02d:%02d" h m
+    | (d, h, m, s) <- secToDHMS sec = printf "%d days %02d:%02d" d h m
 
-secToDHMS :: Integer -> [Integer]
-secToDHMS i = uncurry (:) $ second reverse $ mapAccumL divMod i [60, 60, 24]
+secToDHMS :: Integer -> (Integer, Integer, Integer, Integer)
+secToDHMS i = let (d, [s, m, h]) = mapAccumL divMod i [60, 60, 24]
+              in (d, h, m, s)