Documentation improvements and cleanup relating to the IOE monad

Renamed appIOE to tryIOE (it is analogous to 'try' in the standard libraries).
Removed unused IOE operations & documented the remaining ones.
Removed/simplified superfluous uses of IOE operations.
This commit is contained in:
hallgren
2014-11-10 16:20:01 +00:00
parent c02fef9b6a
commit 831be9393a
6 changed files with 22 additions and 24 deletions

View File

@@ -129,14 +129,16 @@ splitInModuleSearchPath s = case break isPathSep s of
-- | Was: @newtype IOE a = IOE { appIOE :: IO (Err a) }@
type IOE a = IO a
ioe :: IO (Err a) -> IOE a
ioe io = err fail return =<< io
--ioe :: IO (Err a) -> IOE a
--ioe io = err fail return =<< io
appIOE :: IOE a -> IO (Err a)
appIOE ioe = handle (fmap Ok ioe) (return . Bad)
-- | Catch exceptions caused by calls to 'raise' or 'fail' in the 'IO' monad.
-- To catch all 'IO' exceptions, use 'try' instead.
tryIOE :: IOE a -> IO (Err a)
tryIOE ioe = handle (fmap Ok ioe) (return . Bad)
runIOE :: IOE a -> IO a
runIOE = id
--runIOE :: IOE a -> IO a
--runIOE = id
-- instance MonadIO IOE where liftIO io = ioe (io >>= return . return)
@@ -160,6 +162,8 @@ instance Monad IOE where
appIOE $ err raise f x -- f :: a -> IOE a
fail = raise
-}
-- | Print the error message and return a default value if the IO operation 'fail's
useIOE :: a -> IOE a -> IO a
useIOE a ioe = handle ioe (\s -> putStrLn s >> return a)