Sebastian Graf <[email protected]> writes: > OK, so just deriving the instances doesn't yield the expected behavior, > because the `Var` case explicitly mentions `Id`s instead of the type > parameter `b`. > Even if that would be changed, it's not easy to pin down over which parts > of the syntax tree we should 'map'. > Should we include binding sites of local variables? I'm inclined to say No, > but only because I have my concrete use case in mind. > > It's probably best to have non-derived, non-typeclass functions > `foldMapVars :: Monoid m => (Id -> m) -> Expr b -> m`, or a variant where > the mapping function also gets supplied a value of `data NameSite = Lam | > Let | VarRef` (for lack of a better name). > Agreed, I think there is enough subtlety here that it's best to be explicit about which things in particular you want to traverse.
Cheers, - Ben
signature.asc
Description: PGP signature
_______________________________________________ ghc-devs mailing list [email protected] http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
