diff options
| author | hallgren <hallgren@chalmers.se> | 2012-06-25 14:01:58 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2012-06-25 14:01:58 +0000 |
| commit | 0a09f3e0b2f25c02589f5e10b4235303cd218d79 (patch) | |
| tree | b370b35404c60d87dead8db89049dc153e689452 /src/compiler/GF/Compile | |
| parent | deec2d4ecfb0af850f4fcf7ce0e14ddcd8baf1ac (diff) | |
Check monad: support for accumulated errors
In addition to warnings, the Check monad in GF.Infra.CheckM can now accumulate
errors. There are two new functions
checkAccumError: Message -> Check ()
accumulateError :: (a -> Check a) -> a -> Check a
The former (with the same type as checkWarn) is used to report an accumulated
(nonfatal) error. The latter converts fatal errors into accumulated errors.
Accumulated errors are reported as regular errors by runCheck.
Also, the Check monad type has been made abstract.
Diffstat (limited to 'src/compiler/GF/Compile')
| -rw-r--r-- | src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs b/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs index 4ece28cda..26308d945 100644 --- a/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs +++ b/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs @@ -458,7 +458,7 @@ data MetaValue type MetaStore = IntMap.IntMap MetaValue data TcResult a = TcOk a MetaStore [Message] - | TcFail [Message] + | TcFail [Message] -- First msg is error, the rest are warnings? newtype TcM a = TcM {unTcM :: MetaStore -> [Message] -> TcResult a} instance Monad TcM where @@ -480,9 +480,9 @@ tcWarn :: Message -> TcM () tcWarn msg = TcM (\ms msgs -> TcOk () ms ((text "Warning:" <+> msg) : msgs)) runTcM :: TcM a -> Check a -runTcM f = Check (\ctxt msgs -> case unTcM f IntMap.empty msgs of - TcOk x _ msgs -> Success x msgs - TcFail msgs -> Fail msgs) +runTcM f = case unTcM f IntMap.empty [] of + TcOk x _ msgs -> do checkWarnings msgs; return x + TcFail (msg:msgs) -> do checkWarnings msgs; checkError msg newMeta :: Sigma -> TcM MetaId newMeta ty = TcM (\ms msgs -> |
