IO operations, part of the Useful module.
- replicateM :: Monad m => Int -> m a -> m [a]
- replicateM_ :: Monad m => Int -> m a -> m ()
- foreach :: Monad m => [a] -> (a -> m b) -> m ()
- while :: Monad m => m Bool -> m a -> m ()
- put :: Show a => a -> IO ()
- write :: Show a => a -> IO ()
- writeln :: Show a => a -> IO ()
- putln :: Show a => a -> IO ()
- mapM_2 :: Monad m => (a -> m b) -> [[a]] -> m ()
- rand :: [a] -> IO a
Documentation
replicateM :: Monad m => Int -> m a -> m [a]Source
repeats an IO function n number of times.
replicateM_ :: Monad m => Int -> m a -> m ()Source
Like replicateM but stores the returns
foreach :: Monad m => [a] -> (a -> m b) -> m ()Source
repeats an IO function for every member of a list, using the list item as an arguement
$ do foreach [1..3] print 1 2 3 $ do foreach "asjkdnsd" putChar asjkdnsd
while :: Monad m => m Bool -> m a -> m ()Source
repeats an IO function until a IO Bool is true
NOTE: Be careful with this function! Better to use recursion. Testing against an item created in the loop will not work.
put :: Show a => a -> IO ()Source
like putStr or putChar but works on any type with "show" defined in a similar way to how print does. Can be thought of as "print" without the trailing linebreak.
NOTE: This means it will print strings with quotes around them. To print strings without quotes use putStr or putStrLn