-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Pure IO monad.
--   
--   Pure IO monad.
@package pure-io
@version 0.2.1


-- | Pure IO monad, intended for educational use.
module PureIO

-- | Run the IO monad. This should be called in succession. Depending on
--   the type of interrupt, this function should be re-run with the same
--   action but with additional input.
runIO :: Input -> IO a -> (Either Interrupt a, Output)

-- | A pure IO monad.
data IO a

-- | User input.
data Input
Input :: ![String] -> !(Map String String) -> Input
[inputStdin] :: Input -> ![String]
[inputFiles] :: Input -> !(Map String String)

-- | IO monad output.
data Output
Output :: ![String] -> !(Map String String) -> Output
[outputStdout] :: Output -> ![String]
[outputFiles] :: Output -> !(Map String String)

-- | Something that interrupts the flow of the IO monad.
data Interrupt

-- | When you receive this interrupt, you should get some standard input
--   from somewhere and then provide it in the <a>Input</a> value next time
--   you call <a>runIO</a>.
InterruptStdin :: Interrupt

-- | When you receive this interrupt, you should consider the computation
--   as ended.
InterruptException :: !IOException -> Interrupt

-- | An IO exception.
data IOException
UserError :: String -> IOException
FileNotFound :: FilePath -> IOException
DirectoryNotFound :: FilePath -> IOException

-- | The same as <a>putStr</a>, but adds a newline character.
putStrLn :: String -> IO ()

-- | Write a string to the standard output device.
putStr :: String -> IO ()

-- | Read a line from standard input.
getLine :: IO String

-- | The readLn function combines <a>getLine</a> and <a>readIO</a>.
readLn :: Read a => IO a

-- | The <a>print</a> function outputs a value of any printable type to the
--   standard output device. Printable types are those that are instances
--   of class <a>Show</a>; <a>print</a> converts values to strings for
--   output using the <a>show</a> operation and adds a newline.
--   
--   For example, a program to print the first 20 integers and their powers
--   of 2 could be written as:
--   
--   <pre>
--   main = print ([(n, 2^n) | n &lt;- [0..19]])
--   </pre>
print :: Show a => a -> IO ()

-- | The <a>readIO</a> function is similar to <a>read</a> except that it
--   signals parse failure to the <a>IO</a> monad instead of terminating
--   the program.
readIO :: Read a => String -> IO a

-- | Throw an IO exception.
throw :: IOException -> IO a

-- | Catch an IO exception.
catch :: IO a -> (IOException -> IO a) -> IO a

-- | The <a>readFile</a> function reads a file and returns the contents of
--   the file as a string. The file is read lazily, on demand, as with
--   <a>getContents</a>.
readFile :: FilePath -> IO String

-- | The computation <a>writeFile</a> <tt>file str</tt> function writes the
--   string <tt>str</tt>, to the file <tt>file</tt>.
writeFile :: FilePath -> String -> IO ()

-- | The computation <a>appendFile</a> <tt>file str</tt> function appends
--   the string <tt>str</tt>, to the file <tt>file</tt>.
--   
--   Note that <a>writeFile</a> and <a>appendFile</a> write a literal
--   string to a file. To write a value of any printable type, as with
--   <a>print</a>, use the <a>show</a> function to convert the value to a
--   string first.
--   
--   <pre>
--   main = appendFile "squares" (show [(x,x*x) | x &lt;- [0,0.1..2]])
--   </pre>
appendFile :: FilePath -> String -> IO ()

-- | The operation <a>doesFileExist</a> returns <a>True</a> if the argument
--   file exists, and <a>False</a> otherwise.
doesFileExist :: FilePath -> IO Bool

-- | <a>removeFile</a> <i>file</i> removes the directory entry for an
--   existing file <i>file</i>.
removeFile :: FilePath -> IO ()

-- | Get all files in the given directory.
getDirectoryContents :: FilePath -> IO [FilePath]
instance GHC.Base.Applicative PureIO.IO
instance GHC.Base.Functor PureIO.IO
instance GHC.Base.Monad PureIO.IO
instance GHC.Read.Read PureIO.Interrupt
instance GHC.Show.Show PureIO.Interrupt
instance GHC.Read.Read PureIO.Output
instance GHC.Show.Show PureIO.Output
instance GHC.Show.Show PureIO.Input
instance GHC.Read.Read PureIO.IOException
instance GHC.Show.Show PureIO.IOException
instance Control.Monad.Trans.Error.Error PureIO.Interrupt
instance GHC.Base.Monoid PureIO.Output
