[Haskell-beginners] Printing the result of a function evaluation
traviserdman at yahoo.com
Mon Mar 8 18:57:19 EST 2010
Why oh why doesn't this work as I expect, and what is the simplest fix?
speedTest 4 = 44
time :: (Show t) => IO t -> IO t
time a = do
start <- getCPUTime
v <- a
end <- getCPUTime
let diff = (fromIntegral (end - start)) / (10^12)
print v -- WHY DOESNT THIS WORK? ALWAYS PRINTS () ....
printf "Computation time: %0.3f sec\n" (diff :: Double)
main :: IO ()
main = do
args <- getArgs
time $ speedTest (read $ head args) `seq` return ()
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners