Difference Argument Order
ashley at semantic.org
Mon May 23 16:14:33 EDT 2005
<Pine.LNX.4.44.0505231120560.2708-100000 at peano.math.uni-bremen.de>,
Henning Thielemann <lemming at henning-thielemann.de> wrote:
> I assume that these function are for computations like
> subtract :: DegreeCentigrade -> Kelvin -> DegreeCentigrade
> diff :: DegreeCentigrade -> DegreeCentigrade -> Kelvin
> and the intentions are different enough to implement distinct functions.
> I assume that there will be an implementation for 'diff' whenever there is
> one for 'subtract' and vice versa, thus considering them as different
> instances of the same class does not seem to be a good design.
They're actually for time:
diffAbsoluteTime :: AbsoluteTime -> AbsoluteTime -> DiffTime
diffUTCTime :: UTCTime -> UTCTime -> UTCDiffTime
Ideally I'd make a two-parameter class, e.g. "class Diff diff abs | abs
-> diff" which would have all three functions, but I'm sticking with
Haskell 98 (plus FFI only) for portability.
Ashley Yakeley, Seattle WA
More information about the Libraries