Merge pull request #117 from GaloisInc/dm/groundfix

Avoid spurious failure when grounding NonceApps
This commit is contained in:
Daniel Matichuk 2021-05-04 16:09:25 -07:00 committed by GitHub
commit 7b51ca3cdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,10 +39,6 @@ module What4.Expr.GroundEval
, groundEq , groundEq
) where ) where
#if !MIN_VERSION_base(4,13,0)
import Control.Monad.Fail( MonadFail )
#endif
import Control.Monad import Control.Monad
import Control.Monad.Trans.Class import Control.Monad.Trans.Class
import Control.Monad.Trans.Maybe import Control.Monad.Trans.Maybe
@ -186,19 +182,19 @@ tryEvalGroundExpr _ (BoundVarExpr _) = mzero
-- | Helper function for evaluating @NonceApp@ expressions. -- | Helper function for evaluating @NonceApp@ expressions.
-- --
-- This function is intended for implementers of symbolic backends. -- This function is intended for implementers of symbolic backends.
evalGroundNonceApp :: MonadFail m evalGroundNonceApp :: Monad m
=> (forall u . Expr t u -> MaybeT m (GroundValue u)) => (forall u . Expr t u -> MaybeT m (GroundValue u))
-> NonceApp t (Expr t) tp -> NonceApp t (Expr t) tp
-> MaybeT m (GroundValue tp) -> MaybeT m (GroundValue tp)
evalGroundNonceApp fn a0 = evalGroundNonceApp fn a0 =
case a0 of case a0 of
Annotation _ _ t -> fn t Annotation _ _ t -> fn t
Forall{} -> lift $ fail $ "The ground evaluator does not support quantifiers." Forall{} -> mzero
Exists{} -> lift $ fail $ "The ground evaluator does not support quantifiers." Exists{} -> mzero
MapOverArrays{} -> lift $ fail $ "The ground evaluator does not support mapping arrays from arbitrary functions." MapOverArrays{} -> mzero
ArrayFromFn{} -> lift $ fail $ "The ground evaluator does not support arrays from arbitrary functions." ArrayFromFn{} -> mzero
ArrayTrueOnEntries{} -> lift $ fail $ "The ground evaluator does not support arrayTrueOnEntries." ArrayTrueOnEntries{} -> mzero
FnApp{} -> lift $ fail $ "The ground evaluator does not support function applications." FnApp{} -> mzero
{-# INLINABLE evalGroundApp #-} {-# INLINABLE evalGroundApp #-}