Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getModificationTime return type is no longer System.ClockTime

Tags:

time

haskell

I'm reading Real World Haskell; in chapter 9 the example uses a function getModificationTime from System.Directory, which had a return type of ClockTime, but I think in the newer version of System.Directory, it has a different return type. :t getModificationTime returns this:

getModificationTime
:: FilePath -> IO time-1.4.0.1:Data.Time.Clock.UTC.UTCTime

I can get it to work by

import Data.Time.Clock

But my question is, why the new return type is

IO time-1.4.0.1:Data.Time.Clock.UTC.UTCTime

not just UTCTime? is it because the type is from a module that's not imported?

And what's the difference between System.Time and Data.Time.Clock? Is the latter preferable?

like image 703
swang Avatar asked Sep 06 '26 06:09

swang


1 Answers

The recommended time functions have changed. Data.Time etc. from the time package is a complete and more logical rewrite of Haskell's time functions. To quote the top of http://hackage.haskell.org/package/old-time-1.1.0.2/docs/System-Time.html:

The standard time library from Haskell 98. This library is deprecated, please look at Data.Time in the time package instead.

like image 164
Ørjan Johansen Avatar answered Sep 08 '26 10:09

Ørjan Johansen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!