diff options
| author | hallgren <hallgren@chalmers.se> | 2013-01-28 16:12:56 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2013-01-28 16:12:56 +0000 |
| commit | 713e883ad7816f0bb0e3cb7f3cb8fc2a636c805b (patch) | |
| tree | 85f332dec1a89a3f246da80b036bbd4a171bd51f /src/compiler/GF/Infra | |
| parent | 3360cc904cf80f02884bf07bd0bfb6ff72d77974 (diff) | |
Better error message for Predef.error
+ Instead of "Internal error in ...", you now get a proper error message with
a source location and a function name.
+ Also added some missing error value propagation in the partial evaluator.
+ Also some other minor cleanup and error handling fixes.
Diffstat (limited to 'src/compiler/GF/Infra')
| -rw-r--r-- | src/compiler/GF/Infra/UseIO.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/compiler/GF/Infra/UseIO.hs b/src/compiler/GF/Infra/UseIO.hs index 756df0679..2fdc42d83 100644 --- a/src/compiler/GF/Infra/UseIO.hs +++ b/src/compiler/GF/Infra/UseIO.hs @@ -32,6 +32,7 @@ import System.CPUTime import System.Cmd import Text.Printf import Control.Monad +import Control.Monad.Trans(MonadIO(..)) import Control.Exception(evaluate) import qualified Data.ByteString.Char8 as BS @@ -126,10 +127,7 @@ putStrLnFlush s = putStrLn s >> hFlush stdout -- * IO monad with error; adapted from state monad -newtype IOE a = IOE (IO (Err a)) - -appIOE :: IOE a -> IO (Err a) -appIOE (IOE iea) = iea +newtype IOE a = IOE { appIOE :: IO (Err a) } ioe :: IO (Err a) -> IOE a ioe = IOE @@ -140,6 +138,9 @@ ioeIO io = ioe (io >>= return . return) ioeErr :: Err a -> IOE a ioeErr = ioe . return +ioeErrIn :: String -> IOE a -> IOE a +ioeErrIn msg (IOE ioe) = IOE (fmap (errIn msg) ioe) + instance Functor IOE where fmap = liftM instance Monad IOE where @@ -149,6 +150,8 @@ instance Monad IOE where appIOE $ err ioeBad f x -- f :: a -> IOE a fail = ioeBad +instance MonadIO IOE where liftIO = ioeIO + ioeBad :: String -> IOE a ioeBad = ioe . return . Bad |
