diff options
Diffstat (limited to 'src/Eval.hs')
| -rw-r--r-- | src/Eval.hs | 13 |
1 files changed, 11 insertions, 2 deletions
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 |