From f203d4f74b40557803134f6bdb0210d157e62810 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 7 May 2018 15:45:10 -0400 Subject: [PATCH] Define a convenience for throwing a free variable error. --- src/Control/Abstract/Environment.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Control/Abstract/Environment.hs b/src/Control/Abstract/Environment.hs index 8de3fa006..4d4dc3512 100644 --- a/src/Control/Abstract/Environment.hs +++ b/src/Control/Abstract/Environment.hs @@ -13,6 +13,7 @@ module Control.Abstract.Environment , lookupEnv , lookupWith , EnvironmentError(..) +, freeVariableError , runEnvironmentError , runEnvironmentErrorWith ) where @@ -84,6 +85,9 @@ deriving instance Show (EnvironmentError value return) instance Show1 (EnvironmentError value) where liftShowsPrec _ _ = showsPrec instance Eq1 (EnvironmentError value) where liftEq _ (FreeVariable n1) (FreeVariable n2) = n1 == n2 +freeVariableError :: Member (Resumable (EnvironmentError value)) effects => Name -> Evaluator location term value effects value +freeVariableError = throwResumable . FreeVariable + runEnvironmentError :: Evaluator location term value (Resumable (EnvironmentError value) ': effects) a -> Evaluator location term value effects (Either (SomeExc (EnvironmentError value)) a) runEnvironmentError = raiseHandler runError