diff --git a/src/Analysis/Abstract/Evaluating.hs b/src/Analysis/Abstract/Evaluating.hs index 55b7f165f..c1c37e08f 100644 --- a/src/Analysis/Abstract/Evaluating.hs +++ b/src/Analysis/Abstract/Evaluating.hs @@ -72,6 +72,7 @@ evaluate :: forall v term. ( Ord v , Ord (LocationFor v) , Evaluatable (Evaluating v) term v (Base term) + , FreeVariables term , Recursive term ) => term @@ -82,6 +83,7 @@ evaluate = run @(Evaluating v) . foldSubterms eval evaluates :: forall v term. ( Ord v , Ord (LocationFor v) + , FreeVariables term , Evaluatable (Evaluating v) term v (Base term) , Recursive term ) diff --git a/src/Control/Monad/Effect/Evaluatable.hs b/src/Control/Monad/Effect/Evaluatable.hs index e18d8763e..9112a7661 100644 --- a/src/Control/Monad/Effect/Evaluatable.hs +++ b/src/Control/Monad/Effect/Evaluatable.hs @@ -26,8 +26,8 @@ import qualified Data.Union as U -- | The 'Evaluatable' class defines the necessary interface for a term to be evaluated. While a default definition of 'eval' is given, instances with computational content must implement 'eval' to perform their small-step operational semantics. class Evaluatable es term v constr where - eval :: SubtermAlgebra constr term (Eff es v) - default eval :: (Fail :< es, Show1 constr) => SubtermAlgebra constr term (Eff es v) + eval :: FreeVariables term => SubtermAlgebra constr term (Eff es v) + default eval :: (Fail :< es, FreeVariables term, Show1 constr) => SubtermAlgebra constr term (Eff es v) eval expr = fail $ "Eval unspecialized for " ++ liftShowsPrec (const (const id)) (const id) 0 expr "" -- | If we can evaluate any syntax which can occur in a 'Union', we can evaluate the 'Union'. diff --git a/src/Data/Syntax.hs b/src/Data/Syntax.hs index 935510fbe..90a77e09d 100644 --- a/src/Data/Syntax.hs +++ b/src/Data/Syntax.hs @@ -152,7 +152,6 @@ instance ( Ord (LocationFor (Value l t)) , Show (LocationFor (Value l t)) , Recursive t , Evaluatable es t (Value l t) (Base t) - , FreeVariables t , Member Fail es , Member (State (EnvironmentFor (Value l t))) es , Member (Reader (EnvironmentFor (Value l t))) es diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index ec8d4f5c0..d88e366d4 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -39,8 +39,7 @@ instance Show1 Function where liftShowsPrec = genericLiftShowsPrec -- TODO: Filter the closed-over environment by the free variables in the term. -- TODO: How should we represent function types, where applicable? -instance ( FreeVariables t - , Semigroup (Cell l (Value l t)) +instance ( Semigroup (Cell l (Value l t)) , Addressable l es , Member (State (EnvironmentFor (Value l t))) es , Member (Reader (EnvironmentFor (Value l t))) es @@ -63,7 +62,6 @@ instance Member Fail es => Evaluatable es t Type.Type Function -- , MonadFresh m -- , MonadEnv Type.Type m -- , MonadStore Type.Type m --- , FreeVariables t -- ) -- => Eval t Type.Type m Function where -- eval recur yield Function{..} = do @@ -96,8 +94,7 @@ instance Show1 Method where liftShowsPrec = genericLiftShowsPrec -- Evaluating a Method creates a closure and makes that value available in the -- local environment. -instance ( FreeVariables t -- To get free variables from the function's parameters - , Semigroup (Cell l (Value l t)) -- lookupOrAlloc +instance ( Semigroup (Cell l (Value l t)) -- lookupOrAlloc , Addressable l es -- lookupOrAlloc , Member (State (EnvironmentFor (Value l t))) es , Member (Reader (EnvironmentFor (Value l t))) es diff --git a/src/Data/Syntax/Expression.hs b/src/Data/Syntax/Expression.hs index bec5e2bbb..329aeaf0e 100644 --- a/src/Data/Syntax/Expression.hs +++ b/src/Data/Syntax/Expression.hs @@ -62,7 +62,6 @@ instance Member Fail es => Evaluatable es t Type.Type Call -- , MonadFresh m -- , MonadGC Type m -- , MonadEnv Type m --- , FreeVariables t -- ) -- => Eval t Type m Call where -- eval recur yield Call{..} = do