quchen / amoeba

Amœba is a distributed network.
Other
18 stars 1 forks source link

Type-safe µs wrappers #44

Closed quchen closed 10 years ago

quchen commented 10 years ago

It's too easy to mistake seconds for milliseconds or microseconds in the current state. Adding a new type would solve this problem for the most part, and make the code much more explicit, like so:

newtype Microseconds = Microseconds Int
      deriving ({- Lots of Int classes -})
quchen commented 10 years ago

Implemented in the above commit.

kvanbere commented 10 years ago

Maybe you could utilize base instead:

type Microseconds = Fixed E6

https://hackage.haskell.org/package/base-4.3.0.0/docs/Data-Fixed.html#t:Fixed

quchen commented 10 years ago

Oh, that looks interesting! I had no idea this even existed in Base. Thanks for the tip!