[Haskell-beginners] How would you implement Instant and Interval
martin.drautzburg at web.de
Tue Oct 27 17:53:59 UTC 2015
If I define an Instant as a point in Time and an Interval as the difference between two Instants, and I also want to use
(+) and (-), how can I do this.
My initial thought making them instances of the Num class, but that does not work. (-) is okay on Intervals, but on
Instant it returns a different type (Interval).
Is it possible at all to define a typeclass with (-) :: Instant -> Instant -> Interval without using language extensions?
More information about the Beginners