hermit-1.0.0.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 :: Clause -> Clause -> Bool Source

Determine if the left Clause proves the right Clause. Here, proves means that the clause is a substitution instance of the left one, where the top-level binders of the left clause are the holes.

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

Determine if the right Clause is a substitution instance of the left Clause (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.