-- | This combinator combines 'getBoundVars' with the generic 'hfoldl' function.
hfoldlBoundVars :: forall f a b v i . (HasVars f v, HTraversable f)
                  => (b -> Set v ->  a :=> b) -> b -> f a i -> b
hfoldlBoundVars f e t = let n :: f (Numbered a) i
                            n = number t
                            m = bindsVars n
                            trans :: b -> Numbered a :=> b
                            trans x (Numbered i y) = f x (lookupNumMap Set.empty i m) y
                       in hfoldl trans e n
hfoldlBoundVars :: forall f a b v i . (HasVars f v, HTraversable f)
                  => (b -> Set v ->  a :=> b) -> b -> f a i -> b
hfoldlBoundVars f e t = let n :: f (Numbered a) i
                            n = number t
                            m = bindsVars n
                            trans :: b -> Numbered a :=> b
                            trans x (Numbered i y) = f x (lookupNumMap Set.empty i m) y
                       in hfoldl trans e n
hfoldlBoundVars f e t = let n :: f (Numbered a) i
                            n = number t
                            m = bindsVars n
                            trans :: b -> Numbered a :=> b
                            trans x (Numbered i y) = f x (lookupNumMap Set.empty i m) y
                       in hfoldl trans e n