haskell / time

A time library
http://hackage.haskell.org/package/time
Other
118 stars 78 forks source link

Keep Pico unit explicit when converting to and from DiffTime #241

Open VictorCMiraldo opened 1 year ago

VictorCMiraldo commented 1 year ago

(Re-submitting a patched #237, inlining the description for convenience)

The conversion of picoseconds to and from DiffTime doesn't keep the unit explicit. Which can be confusing and is not homogeneous with the same conversion, but to and from NominalDiffTime. This is a very simple PR to make the API a little more consistent.

@AshleyYakeley, if this is still not correct, please let me know, I'm happy to fix it :)

AshleyYakeley commented 1 year ago

No reason to get rid of picosecondsToDiffTime, diffTimeToPicoseconds, is there?

VictorCMiraldo commented 1 year ago

The reason was to homogenize the interface of DiffTime and NominalDiffTime, providing the same functions with similar names.

That being said, if we rather not remove somethint but still want a homogeneous API, we could instead add nominalDiffTimeToPicoseconds and picosecondsToNominalDiffTime.

What do you think?

AshleyYakeley commented 1 year ago

So this is a breaking change in any case and I would prefer to break as little as possible. The whole point of picoseconds is that is the underlying Integer type, that, for example, the Enum instance is based on.

VictorCMiraldo commented 1 year ago

That's fair! I'll bring them back later today or tomorrow!