module Language.Haskell.Refact.Utils.RenamedSourceUtils
(
getFreeVariables
) where
import qualified GHC as GHC
import qualified NameSet as GHC
import qualified Data.Generics as SYB
import qualified GHC.SYB.Utils as SYB
getFreeVariables :: (SYB.Data t, SYB.Typeable t) => t -> [GHC.NameSet]
getFreeVariables t = res
where
res = SYB.everythingStaged SYB.Renamer (++) []
([] `SYB.mkQ` bind) t
bind ((GHC.FunBind _ _ _ _ fvs _)::(GHC.HsBindLR GHC.Name GHC.Name)) = [fvs]
bind ((GHC.PatBind _ _ _ fvs _) ::(GHC.HsBindLR GHC.Name GHC.Name)) = [fvs]
bind _ = []