Is there a Haskell timeline

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)

+5
source share
5 answers

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.

.

+8

, .

, UTCTime , ( Haskell). LocalTime ZonedTime UTC , , . , , .

+3

.

(, 09:27, 14 1821 .) (, 6 ).

. ; ? ; . .

, , .

, time? . , , , , ...

+2

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.

+1
source

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.

0
source

All Articles