Skip to content

Instantly share code, notes, and snippets.

@dorchard
Last active November 13, 2024 09:16
Show Gist options
  • Save dorchard/daa447ce2538ef3ba614d72310dff4d1 to your computer and use it in GitHub Desktop.
Save dorchard/daa447ce2538ef3ba614d72310dff4d1 to your computer and use it in GitHub Desktop.
Generating random numbers in (GHC) Haskell without requiring another package
import GHC.Clock -- imported from the `base` library
rand :: IO Double
rand = do { x <- getMonotonicTime; return $ x - fromInteger (floor x) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment