Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created January 2, 2015 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/7bb941136a1485bfa82d to your computer and use it in GitHub Desktop.
Save shigemk2/7bb941136a1485bfa82d to your computer and use it in GitHub Desktop.
{-# LANGUAGE UnboxedTuples #-}
import GHC.Base
import System.Random
dice = getStdRandom $ randomR (1, 6) :: IO Int
main = IO $ \s ->
let (# s1, d #) = unIO (dice) s
(# s2, r #) = unIO (print d) s1
in (# s2, r #)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment