From a6247056a63d52b2253c4c88a0c9b988aaa4ebcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 13 Sep 2026 11:20:00 +0200 Subject: Replace IO-based fail with custom MonadFail instance for Eval --- src/Eval.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/Eval.hs') diff --git a/src/Eval.hs b/src/Eval.hs index bd011cb..9d83758 100644 --- a/src/Eval.hs +++ b/src/Eval.hs @@ -48,10 +48,19 @@ textEvalError :: EvalError -> Text textEvalError (OtherEvalError text) = text -type Eval a = ReaderT EvalInput (ExceptT EvalError IO) a +newtype Eval a = Eval (ReaderT EvalInput (ExceptT EvalError IO) a) + deriving + ( Functor, Applicative, Monad + , MonadReader EvalInput + , MonadError EvalError + , MonadIO + ) + +instance MonadFail Eval where + fail = throwError . OtherEvalError . T.pack runEval :: Eval a -> EvalInput -> IO (Either EvalError a) -runEval action einput = runExceptT $ flip runReaderT einput action +runEval (Eval action) einput = runExceptT $ flip runReaderT einput action eval :: forall ctx a. ctx -> Expr ctx a -> Eval a -- cgit v1.2.3