Skip to content

Instantly share code, notes, and snippets.

@CarstenKoenig
Created July 18, 2016 08:26
Show Gist options
  • Select an option

  • Save CarstenKoenig/d487a68b325d7f43f053c6df6cbcffde to your computer and use it in GitHub Desktop.

Select an option

Save CarstenKoenig/d487a68b325d7f43f053c6df6cbcffde to your computer and use it in GitHub Desktop.
just to show some simple things
module Unsafe where
import System.Random
import System.IO.Unsafe(unsafePerformIO)
generateUUID :: () -> String
generateUUID () = show $ unsafePerformIO (randomIO :: IO Int)
wuiPanel :: () -> IO String
wuiPanel () = do
return $ "Hey " ++ uuid
where
uuid = generateUUID ()
generateUUID' :: String
generateUUID' = show $ unsafePerformIO (randomIO :: IO Int)
wuiPanel' :: IO String
wuiPanel' = do
return $ "Hey " ++ uuid
where
uuid = generateUUID'
----------------------------------
-- Example run in GHCi
> wuiPanel'
"Hey 8392539819302952191"
> wuiPanel'
"Hey 8392539819302952191"
> wuiPanel'
"Hey 8392539819302952191"
> wuiPanel()
"Hey 5880651860501659846"
> wuiPanel()
"Hey 3355626182084962896"
> wuiPanel()
"Hey 6303352265620553643"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment