hermit-0.7.1.0: Haskell Equational Reasoning Model-to-Implementation Tunnel

Safe HaskellNone
LanguageHaskell2010

HERMIT.Dictionary.Fold

Contents

Synopsis

Fold/Unfold Transformation

runFoldR :: (BoundVars c, Monad m) => CompiledFold -> Rewrite c m CoreExpr Source

Rewrite using a compiled fold. Useful inside traversal strategies like anytdR, because you can compile the fold once outside the traversal, then apply it everywhere in the tree.

Unlifted fold interface

fold :: BoundVars c => [Equality] -> c -> CoreExpr -> Maybe CoreExpr Source

Attempt to apply a list of Equalitys to the given expression, folding the left-hand side into an application of the right-hand side. This implementation depends on Equality being well-formed. That is, both the LHS and RHS are NOT lambda expressions. Always use mkEquality to ensure this is the case.

compileFold :: [Equality] -> CompiledFold Source

Compile a list of Equality's into a single fold matcher.

runFold :: BoundVars c => CompiledFold -> c -> CoreExpr -> Maybe CoreExpr Source

Attempt to fold an expression using a matcher in a given context.

runFoldMatches :: BoundVars c => CompiledFold -> c -> CoreExpr -> Maybe (CoreExpr, VarEnv CoreExpr) Source

Attempt to fold an expression using a matcher in a given context. Return resulting expression and a map of what when in the holes in the pattern.

proves :: Quantified -> Quantified -> Bool Source

Determine if the left Quantified proves the right one. Here, proves means that the right Quantified is a substitution of the left one, where only the top-level binders of the left Quantified can be substituted.

lemmaMatch :: [Var] -> Quantified -> Quantified -> Maybe (VarEnv CoreExpr) Source

Determine if the right Quantified is a substitution instance of the left Quantified (which is a pattern with a given set of holes).

Equality

data Equality Source

An equality is represented as a set of universally quantified binders, and the LHS and RHS of the equality.

flipEquality :: Equality -> Equality Source

Flip the LHS and RHS of a Equality.