I want to build a function with a type signature Time t => t -> Bool. When viewing documentation Data.Time there are several different types of working time, for example UTCTime, LocalTimeand ZonedTime, but I can not find a class that unites them. Is there such a method, or should I handle the time the same way Num? (i.e. continuum)
Time t => t -> Bool
UTCTime
LocalTime
ZonedTime
Num
A vector space package has a typeclass affine space .
Diff pis the type of time duration (which should be an instance VectorSpace), and pis the type of time. For comparison, you will need an additional instance Ord.
Diff p
VectorSpace
p
Ord
.
, .
, UTCTime , ( Haskell). LocalTime ZonedTime UTC , , . , , .
(, 09:27, 14 1821 .) (, 6 ).
. ; ? ; . .
, , .
, time? . , , , , ...
time
HasTime time-lens.
It gives you (both read and write) access to the component of TimeOfDayall these structures. So, if you implement your function for TimeOfDay, it can be easily generalized to LocalTime, ZonedTimeand UTCTime.
TimeOfDay
According to the documentation ( http://www.haskell.org/ghc/docs/7.0.2/html/libraries/time-1.2.0.3/Data-Time-Format.html all UTCTime, ZonedTime, and LocalTime are instances of FormatTime types and ParseTime, which should be what you are looking for.