summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Eval.hs13
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