diff --git a/src/Lib/TopContext.newt b/src/Lib/TopContext.newt index babc5f7..055136e 100644 --- a/src/Lib/TopContext.newt +++ b/src/Lib/TopContext.newt @@ -43,8 +43,7 @@ instance Show TopContext where emptyTop : ∀ io. {{Monad io}} {{HasIO io}} -> io TopContext emptyTop = do let mcctx = MC emptyMap Nil 0 CheckAll - errs <- newIORef $ the (List Error) Nil - pure $ MkTop emptyMap Nil emptyMap Nil emptyMap mcctx 0 errs emptyMap + pure $ MkTop emptyMap Nil emptyMap Nil emptyMap mcctx 0 Nil emptyMap setFlag : QName → FC → EFlag → M Unit @@ -91,4 +90,4 @@ addHint qn = do addError : Error -> M Unit addError err = do top <- getTop - modifyIORef top.errors (_::_ err) + modifyTop [ errors $= _::_ err ] diff --git a/src/Lib/Types.newt b/src/Lib/Types.newt index 9e76a18..faa1061 100644 --- a/src/Lib/Types.newt +++ b/src/Lib/Types.newt @@ -433,7 +433,7 @@ record TopContext where -- Global values verbose : Int -- command line flag - errors : IORef (List Error) + errors : List Error ops : Operators -- we'll use this for typechecking, but need to keep a TopContext around too. diff --git a/src/Main.newt b/src/Main.newt index e54fdc8..cd32e52 100644 --- a/src/Main.newt +++ b/src/Main.newt @@ -165,19 +165,15 @@ processModule importFC base stk qn@(QN ns nm) = do top <- getTop let mod = MkModCtx csum top.defs top.metaCtx top.ops - errors <- liftIO {M} $ readIORef top.errors - if stk /= Nil && length' errors == 0 + if stk /= Nil && length' top.errors == 0 then dumpModule qn src mod else pure MkUnit let modules = updateMap modns mod top.modules modifyTop [modules := modules] - (Nil) <- liftIO {M} $ readIORef top.errors - | errors => do - -- we're now showing errors when they occur, so they're next to debug messages - -- traverse (putStrLn ∘ showError src) errors - exitFailure "Compile failed" + let (Nil) = top.errors + | errors => exitFailure "Compile failed" logMetas $ reverse $ listValues top.metaCtx.metas pure src where @@ -199,7 +195,7 @@ showErrors : String -> String -> M Unit showErrors fn src = do top <- getTop -- TODO {M} needed to sort out scrutinee - (Nil) <- liftIO {M} $ readIORef top.errors + let (Nil) = top.errors | errors => do traverse (putStrLn ∘ showError src) errors exitFailure "Compile failed"