diff options
| author | hallgren <hallgren@chalmers.se> | 2014-11-10 16:20:01 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2014-11-10 16:20:01 +0000 |
| commit | c707575bd7751ac3b03371edba478e37d3488448 (patch) | |
| tree | 4d16d9dabed27b5d977d3d4d84a4bb317dff4a4a /src/compiler/GF/Infra | |
| parent | 33571ba44f2a42502722a3b025b448efe1f0ab88 (diff) | |
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.
Diffstat (limited to 'src/compiler/GF/Infra')
| -rw-r--r-- | src/compiler/GF/Infra/UseIO.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/compiler/GF/Infra/UseIO.hs b/src/compiler/GF/Infra/UseIO.hs index b5ef38f49..14120d811 100644 --- a/src/compiler/GF/Infra/UseIO.hs +++ b/src/compiler/GF/Infra/UseIO.hs @@ -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) |
