Stop using "Int" for microsecond delays in "base"

Erik Hesselink hesselink at gmail.com
Thu Apr 21 10:01:53 CEST 2011


On Wed, Apr 20, 2011 at 22:31, Neil Mitchell <ndmitchell at gmail.com> wrote:
>> I always end up with a wrapper around it, taking a NominalDiffTime; I could
>> never be sure whether threadDelay interpreted its argument as
>> milli-/micro-/nano-seconds without looking it up.
>
> I too always end up with a wrapper, but my wrapper takes a Double,
> which is in seconds. Seconds are easy, and a Double means that you can
> specify ridiculously long intervals, and for short intervals you have
> high precision. I find it much easier to write sleep 5, when I want to
> sleep for 5 seconds, than putting in some multiplication factor.

Note that NominalDiffTime has all the necessary instances to able to
do the same. I.e. (5 :: NominalDiffTime), (5.123 :: NominalDiffTime),
or (10^100 :: NominalDiffTime). These numbers are also interpreted as
seconds, with a precision up to 10^-12.

Erik



More information about the Libraries mailing list