In the documentation for Data.Time.Clock I see this:
Conversion functions will treat it as seconds. It has a precision of 10^-12 s
What function will turn that NominalDiffTime
into a Double
? No luck hoogling it
You need to pay more attention to the list of instances for the type. One of the listed instances is Real NominalDiffTime
. This allows you to use realToFrac :: (Real a, Fractional b) :: a -> b
to convert to Double
, since Double
is an instance of Fractional
.
Since NominalDiffTime
has a Real
instance, and Double
has a Fractional
instance, you can use realToFrac
as if it had the type signature NominalDiffTime -> Double
. Of course, realToFrac
is more polymorphic than that, and so you might need to give it hints exactly what types you want to convert sometimes. But it certainly is capable of that conversion, if it can figure out the types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With