import System.Random
ioActions :: [IO ()]
ioActions = [print "Hello",
putStr "World",
getChar >> return ()]
sequence_' :: [IO a] -> IO ()
sequence_' [] = return ()
sequence_' (x:xs) = do x
sequence_' xs
f :: Int -> Maybe Int
f 0 = Nothing
f x = Just x
g :: Int -> Maybe Int
g 100 = Nothing
g x = Just x
h :: Int -> Maybe Int
h 10 = Nothing
h x = Just x
test :: Int -> Maybe Int
test x = do y <- f x
z <- g y
h z
squares xs = do x <- xs
return (x*x)
pairs xs ys = do
x <- xs
y <- ys
return (x,y)
myRns :: Int -> [Float]
myRns seed = randSeq (mkStdGen seed)
where randSeq gen = let (v,g2) = random gen
in v:randSeq g2
in v:randSeq g2
data Coin = Heads | Tails deriving (Show, Enum, Bounded)
instance Random Coin where
randomR (a,b) g =
let (x, g') = randomR (fromEnum a, fromEnum b) g
in (toEnum x, g')
random g = randomR (minBound, maxBound) g