
Bayley, Alistair wrote:
From: Keean Schupke [mailto:k.schupke@imperial.ac.uk]
data Gregorian = Gregorian { second :: Int, minute :: Int, hour :: Int, dayOfMonth :: Int, dayOfWeek :: Int, weekOfYear :: Int, monthOfYear :: Int, Year :: Int } -- enumerations may make more sense for dayOfWeek/monthOfYear
I don't like the redundancy here. dayOfWeek and weekOfYear can (and should) be derived from the dayOfMonth+monthOfYear+year. Having to specify them in addition to the other fields is a major PITA, and one of the reasons the current CalendarTime library is so unsavoury (why do I need to say what day of the week it is? pah).
Alistair.
For some functions it makes sense, for reverse calculations (Calendar -> TAI) it can save a lot of time to just fill out some fields... I was thinking of cron like functionality where you want to represent a repeat time (like every monday at 8pm)... But this would require each field to have a type like: data Gregorian = Gregorian { second :: [Int], minute :: [Int], hour :: [Int], dayOfMonth :: [Int], dayOfWeek :: [Int], weekOfYear :: [Int], monthOfYear :: [Int], year :: [Int] } anytime = { second = [], minute = [], hour = [], dayOfMonth = [], dayOfWeek = [], weekOfYear = [], monthOfYear = [], year = [] } recordMyProgram = anytime { dayOfWeek = [1,3], hour = [21] } So my program gets recorded every monday and wednesday at 9pm. Keean.