I think you are asking for a function to find the free variable of a HsType:
freeVars :: HsType Ps -> [Located RdrName] Then you could see if the free vars intersects the binders. Right? If so, try GHC.Rename.HsType.extractHsTyRdrTyVars Simon From: ghc-devs <ghc-devs-boun...@haskell.org> On Behalf Of Tseen She Sent: 06 October 2020 23:19 To: ghc-devs@haskell.org Subject: type parameters in a HsType Hi all, I'm writing a tool that needs to figure out if a type parameter declared on the type constructor (i.e. tcdTyVars DataDecl) is referenced by any of the fields (in the tcdDataDefn). I only care about ConDeclH98 things. Is there a canonical way to do this that doesn't involve me having to traverse the HsType ? In an ideal world I want this signature: HsType -> [HsTyVarBndr GhcPs] -> Bool PS: I think this is probably done in the DeriveFunctor (etc) derivation rules, because they need to figure out which fields to touch, e.g. in gen_Functor_binds, but I don't see where this check would be done. Best regards, Tseen She
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs