foldBindsContainingTyCon :: Monoid r
                        => GHC.TyCon -> (GHC.LHsBind GHC.Id -> r)
                        -> GHC.LHsBinds GHC.Id -> r
foldBindsContainingTyCon tyCon f = everything mappend (mempty `mkQ` go)
  where
    go bind@(L _ (GHC.FunBind {GHC.fun_id=L _ fid}))
      | getAny $ everything mappend (mempty `mkQ` containsTyCon) (GHC.idType fid) = f bind
      where
        containsTyCon tyCon' | tyCon == tyCon' = Any True
        containsTyCon _                        = mempty
    go _ = mempty
foldBindsContainingTyCon :: Monoid r
                        => GHC.TyCon -> (GHC.LHsBind GHC.Id -> r)
                        -> GHC.LHsBinds GHC.Id -> r
foldBindsContainingTyCon tyCon f = everything mappend (mempty `mkQ` go)
  where
    go bind@(L _ (GHC.FunBind {GHC.fun_id=L _ fid}))
      | getAny $ everything mappend (mempty `mkQ` containsTyCon) (GHC.idType fid) = f bind
      where
        containsTyCon tyCon' | tyCon == tyCon' = Any True
        containsTyCon _                        = mempty
    go _ = mempty
foldBindsContainingTyCon tyCon f = everything mappend (mempty `mkQ` go)
  where
    go bind@(L _ (GHC.FunBind {GHC.fun_id=L _ fid}))
      | getAny $ everything mappend (mempty `mkQ` containsTyCon) (GHC.idType fid) = f bind
      where
        containsTyCon tyCon' | tyCon == tyCon' = Any True
        containsTyCon _                        = mempty
    go _ = mempty