retrie-0.1.1.1: A powerful, easy-to-use codemodding tool for Haskell.

Safe HaskellNone
LanguageHaskell2010

Retrie.GroundTerms

Synopsis

Documentation

type GroundTerms = HashSet String Source #

'Ground Terms' are variables in the pattern that are not quantifiers. We use a set of ground terms to save time during matching by filtering out files which do not contain all the terms. We store one set of terms per pattern because when filtering we must take care to only filter files which do not match any of the patterns.

Example:

Patterns of 'forall x. foo (bar x) = ...' and 'forall y. baz (quux y) = ...'

groundTerms = [{foo, bar}, {baz, quux}]

Files will be found by unioning results of these commands:

grep -R --include "*.hs" -l foo dir | xargs grep -l bar grep -R --include "*.hs" -l baz dir | xargs grep -l quux

If there are no ground terms (e.g. 'forall f x y. f x y = f y x') we fall back to 'find dir -iname "*.hs"'. This case seems pathological.