문제

I need to find a good value to feed into mkStdGen as a seed.

The first thing I'd normally do is just use the ticks since the beginning of the epoch, however, to do that I use getClockTime from System.Time, which according to hackage is deprecated, in favour of Data.Time. The latter doesn't seem to expose this functionality though.

Is there a better way to generate a seed for this value? Or should I just ignore the deprecation warning?

도움이 되었습니까?

해결책

This is usually unnecessary, because the global StdGen is seeded with the current time at startup. So you can just use randomIO and randomRIO and have an implicit, IO-based random number generator, or getStdGen and the usual pure functions for a more explicit one.

다른 팁

Are you looking for getPOSIXTime (docs)?

Footnote: Please note that this DOES NOT return the number of ticks since the beginning of any epoch, and you should never claim that it does. It returns the "POSIX time" which defined based on a lossy conversion from UTC time, and UTC time is not useful for determining intervals between dates without an up-to-date conversion database.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top