th-alpha

Alpha equivalence for TH Exp

https://github.com/jkarni/th-alpha

Latest on Hackage:0.2.1.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD-3-Clause licensed by Julian K. Arni
Maintained by Julian K. Arni

Compare TH expressions (or clauses, patterns, etc.) for alpha equivalence. That is, compare for equality modulo the renaming of bound variables.

areExpAEq [| \x -> x |] [| \y -> y |]
-- True
do
   let x = mkName "x"
   let y = mkName "y"
   runQ $ (LamE [VarP x] (VarE x)) @= (LamE [VarP y] (VarE y))
-- True

This can be useful when for instance testing libraries that use Template Haskell - usually correctness is only defined up to alpha equivalence.