serokell / o-clock

:hourglass: Type-safe time units in Haskell
Mozilla Public License 2.0
49 stars 6 forks source link

Implement 'toNum' function #71

Closed chshersh closed 6 years ago

chshersh commented 6 years ago

Some libraries still use Integer to represent time. It would be nice to have some toNum function so instead of

mskDifference :: POSIXTime
mskDifference = 10800 -- 3 hours

We could write in more safe way:

mskDifference :: POSIXTime
mskDifference = toNum @Second $ hour 3

Current possible solution:

mskDifference :: POSIXTime
mskDifference = floor $ toUnit @Second $ hour 3

Dunno is it worth to have such conversion function...