
Hi, I have this code: class (Show a) => HVFSStat a where ... vModificationTime :: a -> EpochTime ... class (Show a) => HVFS a where ... vGetModificationTime :: a -> FilePath -> IO ClockTime ... vGetModificationTime fs fp = do s <- vGetFileStatus fs fp return $ TOD (fromIntegral (withStat s vModificationTime)) 0 This works fine in Hugs 200311, but in Hugs 20050308, I get: ERROR "/home/jgoerzen/tree/projects/missingh/MissingH/IO/HVFS.hs":198 - Implementation of vGetModificationTime requires extra context *** Expected type : HVFS a => a -> FilePath -> IO ClockTime *** Missing context : Integral CTime I can't figure out what's going on; the type of the expression (withStat s vModificationTime) is EpochTime, and I don't understand why Hugs would have decided to break this code. Thanks, John

On 2005-04-05, John Goerzen
Hi,
I have this code:
Well, sorry for the dup (geez, I feel like a slashdot editor now...) Anyway, the question remains: what is a portable way of converting an EpochTime to a TOD x y value, that works on Hugs 2003, Hugs 2005, GHC 6.2, and GHC 6.4? -- John

On 2005-04-05, John Goerzen
On 2005-04-05, John Goerzen
wrote: Anyway, the question remains: what is a portable way of converting an EpochTime to a TOD x y value, that works on Hugs 2003, Hugs 2005, GHC 6.2, and GHC 6.4?
And to follow up to myself yet again, I just checked this into MissingH (feel free to steal for fptools): {- | Converts an Epoch time represented with an arbitrary Real to a ClockTime. This input could be a CTime from Foreign.C.Types or an EpochTime from System.Posix.Types. -} epochToClockTime :: Real a => a -> ClockTime epochToClockTime x = TOD seconds secfrac where ratval = toRational x seconds = floor ratval secfrac = floor $ (ratval - (seconds % 1) ) * picosecondfactor picosecondfactor = 10 ^ 12 -- John
participants (1)
-
John Goerzen