I have piece of code like this in my Haskell program:
...
start <- getCurrentTime
...
end <- getCurrentTime
...
delta = end `diffUTCTime` start
...
After this, delta has type NominalDiffTime. As written in the documentation, this type in inherited from Num, and I want to print it with 3 (for example) places after decimal dot. However, using something like printf "%.3f" delta doesn’t work: No instance for (PrintfArg NominalDiffTime).
How to do this correctly?
You can convert it to a
PrintfArgtype to print it in the desired format, e.g.does it.