RE: Concerning Time.TimeDiff
At 11:21 02/06/03 +0100, Simon Peyton-Jones wrote:
The H98 Time module is probably broken in many ways.
Rather than try to fix it incrementally, I think it'd be most productive if the interested parties simply got together and agreed an interface for a new Time module, even if it's incompatible with the old one. Perhaps Graham is The Man!
I don't feel especially well-qualified, but if I can contribute in some small ways... I've taken another look at the Haskell Report description [1], and beyond clarification of some points it doesn't seem obviously broken to me. Others may have some views... a pointer to earlier discussion might help. The only thing I see offhand that I'd be tempted to change is the TimeDiff structure, in which I'd suggest dropping the tdYear, tdMonth fields, and changing tdDay to ::Integer. (This still fudges the issue of leap-seconds in time-differences, but I don't think any errors thus introduced would affect any but the most specialized of applications.) [see comments below] Thus, maybe something like this (which is indicative of a direction, not my last word on this): [[ data TimeDiff = TimeDiff { tdDay :: Integer -- -(maxInt*365) to +(maxInt*365) , tdHour, tdMin, tdSec :: Int -- 0 to 23, 0 to 59, 0 to 61 , tdPicosec :: Integer -- 0 to 10^12-1 } deriving (Eq, Ord, Read, Show) ]] Taking a wider view, I'd ask: what are the common uses for the Time library? As I mentioned previously, I don't think it's realistic to try and satisfy all possible uses, but the library should provide useful functionality for most common purposes. Some use-cases that come to mind are: - "human-scale" timestamps; attaching a time to information for the purposes of providing additional provenance information to human users. This purpose probably has little use for sub-second granularity. - "computer scale" timestamps; attaching a time to information to ensure unique identification. Monotonicity may be more important than strict accuracy. - Timed event generation in real-time systems - "human scale" measurements of duration (e.g. days, and fractions thereof); e.g. contract durations. - "computer scale" measurements of duration (e.g. seconds and fractions thereof); e.g. race timing. I'd suggest that specialist applications, such as astronomical date measurements (at exactly what date and time will be the next total eclipse of the sun?) which have to take detailed account of interactions between leap-seconds and calendar dates, or social event scheduling (the local start-time of next XYZ conference of functional programming) which have to take account of many time-zone complexities are not to be solved by the Time library. I don't mean to suggest that, say, the CalendarTime data structure not be useful for exchanging information with such applications, but that the Time module not be expected to take account of arcane calculations involving leap-seconds or time-zone differences. I think that's enough of my rambling. In summary, I think a review would: (a) scope the purpose of the Time module (b) recommend small rather than extensive changes, and (c) be more specific about describing the data and function semantics #g -- [1] http://www.haskell.org/onlinereport/time.html ------------------- Graham Klyne <GK@NineByNine.org> PGP: 0FAA 69FF C083 000B A2E9 A131 01B9 1C7A DBCA CB5E
Simon Peyton-Jones wrote:
The H98 Time module is probably broken in many ways.
I had a quick look at the official Haskell Libraries Report for the Time module today, and the thing that struck me as most bizarre is the sentence: "It follows RFC 1129 in its use of Coordinated Universal Time (UTC)". What is so strange is the fact that the named RFC has absolutely nothing to say on time representation formats, conversions, timezones, and so on. It is a specification of the NTP protocol, and concentrates on the mechanics of transferring clock information from machine to machine with corrections for skew and transport delays. Much more relevant references for time representation would be ISO 8601, or RFC 3339, which *do* talk about calendar times, clock times, and their conversion. (Although I wouldn't be qualified to speculate about how closely the Haskell Time module resembles either standard.) Graham Klyne <GK@ninebynine.org> writes:
I don't feel especially well-qualified, but if I can contribute in some small ways...
A small surprise to me was that the editor of RFC 3339 "Date and Time on the Internet: Timestamps" is one Graham Klyne, which may not be the same person as you, but perhaps you are more qualified for the job of proposing a new Time module than you admit... :-) Regards, Malcolm
At 11:37 16/06/03 +0100, Malcolm Wallace wrote:
Graham Klyne <GK@ninebynine.org> writes:
I don't feel especially well-qualified, but if I can contribute in some small ways...
A small surprise to me was that the editor of RFC 3339 "Date and Time on the Internet: Timestamps" is one Graham Klyne, which may not be the same person as you, but perhaps you are more qualified for the job of proposing a new Time module than you admit... :-)
:-) Maybe I should explain a little. My editoriship came about because I found myself repeatedly citing a previous version of this document, for which the "heavy lifting" had already been done by Chris Newman, the other editor of RFC 3339. I badgered Chris a few times about moving his document to RFC status so we'd have a stable, persistent reference. In the spirit of "he who asks, gets volunteered", Chris suggested that I take it on. My technical contribution was to be an axe-wielder: the original draft contained a lot of much-debated materials about time-zones. But the immediate goal was for a simple profile of ISO 8601 suitable for conveying protocol timestamps, so I slashed and burned the verbiage surplus for this purpose. You may notice a similar flavour in my suggestions for the Haskell Time module: when discussing time, it's very easy to get dragged into all kinds of arcane requirement, when x%, for some x just slightly less than 100, of applications would be well satisfied by something much simpler. As for the reference to RFC1129, I tend to agree (though using UTC as a common reference is important to time synchronization on the Internet, and RFC3339 reflects this in that times are (usually) expected to be expressed in a form clearly referenced to UTC). As for representation, I guess we need to distinguish between representation for human presentation, and representation for transfers between programs (I've never been quite clear which purpose is meant to be served by Haskell Show and Read classes -- I suspect it's a bit of both). I think an ISO 8601 based format is good for the latter; the former maybe more usefully localized than standardized. Finally, I may have gone quiet on this topic, but I haven't abandoned it. I have some pointers to earlier Haskell mailing list discussions that I've yet to read through before I come barging back. There should come a point when aspects of my own work, relating to scheduled network access controls, will bring me back into this. #g ------------------- Graham Klyne <GK@NineByNine.org> PGP: 0FAA 69FF C083 000B A2E9 A131 01B9 1C7A DBCA CB5E
participants (2)
-
Graham Klyne -
Malcolm Wallace