Andy Gill writes: | As you know, Glasgow is trying to push the IO monad as a general | mechanism for expressing I/O in Haskell. Unfortunately we can't do | some simple things right now. | ......... | ......... | ......... | Now some more user visible IO functions. Because these functions | handle error internally (and fatally) we can return objects of the type | IO. | | > readFileIO :: String -> IO String | > writeFileIO :: String -> String -> IO () | > appendFileIO :: String -> String -> IO () | > deleteFileIO :: String -> IO () | > statusFileIO :: String -> IO String | > readChanIO :: String -> IO String | > appendChanIO :: String -> String -> IO () | > statusChanIO :: String -> IO String | > echoIO :: Bool -> IO () | > getArgsIO :: IO [String] | > getEnvIO :: String -> IO String | > setEnvIO :: String -> String -> IO () This seems sensible. I have long regretted that to adopt Glasgow's monadic IO package required us (as far as I could see) to forsake the IO facilities available through the Haskell Dialogue. This proposal effectively answers that. We use an IO package which originates from Andy Gordon (ADG) [1], and have adapted it (not very much) to give us the facilities listed above. So we have: [In ADG's package, IO --> Job, IO () -> Task, thenIO --> ">>="] > appendChanJ :: String -> String -> Task > getEnvJ :: String -> Job String > getArgsJ :: Job [String] > getProgNameJ :: Job String > writeFileJ :: String -> String -> Task > appendFileJ :: String -> String -> Task > readFileJ :: String -> Job String Ie exactly (almost) as Andy Gill's proposal! In fact all the above are implemented on top of two low-level functions: > outputReq :: Request -> Task > inputResp :: Job Response although I didn't realise that every Request must have exactly one Response (true?) so I could/should provide: > processRequestJ :: Request -> Job Response > processRequestJ req = outputReq >> inputResp again, mirroring Andy Gill's proposal. However, we treat stdin specially, to provide: > getChar :: Job Char -- Read next char from stdin > readRemainingInputJ :: Job String -- Read all remainder of stdin which makes interactive programs easy to write. I expect this can be generalised to allow character-by-character reading of any channel/file, but I haven't got my brain round this yet. The package also incorporates soft error handling which is a delight to to use --- see [1]. I am wholly persuaded by monadic IO, and look forward to it becomming the default Haskell style --- and a standard emerging. [1] A D Gordon, Funtional Programming and Input/Output, University of Cambridge, 1993 Ian ====================================================================== Ian Poole MRC Human Genetics Unit Western General Hospital Janet: [EMAIL PROTECTED] Crewe Road Tel. : +44-31-332-2471 Edinburgh EH4 2XU, UK. Fax. : +44-31-343-2620 ======================================================================