swang
swang

Reputation: 5249

getModificationTime return type is no longer System.ClockTime

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?

Upvotes: 3

Views: 314

Answers (1)

Ørjan Johansen
Ørjan Johansen

Reputation: 18199

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.

Upvotes: 1

Related Questions