Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Haskell Time Typeclass

Tags:

haskell

I want to build a function with type signature Time t => t -> Bool. When looking at the documentation of Data.Time there are several different types that work on time, such as: UTCTime, LocalTime, and ZonedTime, but I find no typeclass that unifies them. Is there any such one or should I treat time just as a Num? (i.e. a continuum)

like image 526
Magnus Kronqvist Avatar asked Jul 20 '12 10:07

Magnus Kronqvist


1 Answers

The vector-space package has a affine space typeclass.

Diff p is here the time duration type (which should be an instance of VectorSpace), and p is the time point type. You'll need an extra Ord instance for comparisons.

This provides you with linear interpolation between time points for free.

like image 155
Alexandre C. Avatar answered Oct 13 '22 20:10

Alexandre C.