home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 876 / hugs.sis / IOExtensions.hs < prev    next >
Encoding:
Text File  |  2000-09-21  |  1.4 KB  |  45 lines

  1. -----------------------------------------------------------------------------
  2. -- Non-standard extensions to IO monad.
  3. --
  4. -- Binary file extensions:
  5. --
  6. --   readBinaryFile         : versions of readFile, writeFile, appendFile,
  7. --   writeBinaryFile        : and openFile for use on binary files
  8. --   appendBinaryFile       : (These don't do LF <-> CR-LF translation on
  9. --   openBinaryFile         :  DOS/Windows systems.)
  10. --
  11. -- Miscellaneous extensions:
  12. --
  13. --   getCh                  : like getChar but doesn't echo to screen
  14. --   argv                   : value returned by getArgv     
  15. -- 
  16. -- None of these operations can be implemented in standard Haskell using the
  17. -- standard Haskell prelude.
  18. --
  19. -- Suitable for use with Hugs 98
  20. -----------------------------------------------------------------------------
  21.  
  22. module IOExtensions(
  23.     readBinaryFile, writeBinaryFile, appendBinaryFile,
  24.     openBinaryFile, 
  25.         getCh,
  26.     argv
  27.     ) where
  28.  
  29. import System( getArgs )
  30. import IO( Handle, IOMode )
  31. import IOExts( unsafePerformIO )
  32.  
  33. argv :: [String]
  34. argv = unsafePerformIO getArgs
  35.  
  36. primitive writeBinaryFile        :: FilePath -> String -> IO ()
  37. primitive appendBinaryFile       :: FilePath -> String -> IO ()
  38. primitive readBinaryFile         :: FilePath -> IO String
  39. primitive openBinaryFile         :: FilePath -> IOMode -> IO Handle
  40.  
  41. primitive getCh                  :: IO Char -- non-echoing getchar
  42.  
  43.  
  44.  
  45.