Hello everyone. I have a quick question about Time.
I was talking about Haskell on the Arch Linux forums today, and someone was trying to put together code that would print a series of periods for, say, 5 minutes. I felt like using 'until' would be the most correct way of going about it, but when I tried to do it...
import Time
makeLater :: ClockTime -> ClockTime
makeLater t = addToClockTime (TimeDiff 0 0 0 0 0 5 0) t
updateTime :: ClockTime -> ClockTime
updateTime t = t
main = do
start <- getClockTime
until ((==) $ makeLater start) (updateTime) start
putStrLn "done"
Now, updateTime isn't correct. And this wouldn't print any periods. But GHC is giving me errors:
$ runhaskell temp.hs
temp.hs:11:2:
Couldn't match expected type `IO t'
against inferred type `ClockTime'
In the expression:
until ((==) $ makeLater start) (updateTime) start
In a 'do' expression:
until ((==) $ makeLater start) (updateTime) start
In the expression:
do start <- getClockTime
until ((==) $ makeLater start) (updateTime) start
putStrLn "done"
I'm not sure where IO t is coming from at all. Am I even on the right track? How would you write this code?