From f1b4770ff17ff35f86ad8b263903caba6cfb8d1e Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 8 Mar 2018 11:04:31 -0500 Subject: [PATCH] Define a helper to lift an evaluator into an underlying type. --- src/Control/Abstract/Analysis.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Control/Abstract/Analysis.hs b/src/Control/Abstract/Analysis.hs index fc88ebbff..c121cf4ee 100644 --- a/src/Control/Abstract/Analysis.hs +++ b/src/Control/Abstract/Analysis.hs @@ -2,6 +2,7 @@ module Control.Abstract.Analysis ( MonadAnalysis(..) , delegateAnalyzeTerm +, liftEvaluate , module X , Subterm(..) , SubtermAlgebra @@ -45,3 +46,13 @@ delegateAnalyzeTerm term = pack1 (analyzeTerm (second unpack1 <$> term)) where pack1 = coerce unpack1 :: Coercible (t m (ValueFor m)) (m (ValueFor m)) => t m (ValueFor m) -> m (ValueFor m) unpack1 = coerce + +liftEvaluate :: ( term ~ TermFor m + , term ~ TermFor (t m) + , value ~ ValueFor m + , value ~ ValueFor (t m) + , Coercible (m value) (t m value) + ) + => (term -> m value) + -> (term -> t m value) +liftEvaluate evaluate = coerce . evaluate