[Haskell-cafe] Using multiplate to get free variables from a syntax tree

Brent Yorgey byorgey at seas.upenn.edu
Fri Feb 24 20:13:32 CET 2012

On Thu, Feb 23, 2012 at 01:18:22PM -0800, Matt Brown wrote:
> Hi all,
> I'm reading the haskellwiki article on multiplate. Is it possible to
> modify the getVariablesPlate example to return the free variables?
> One idea I had is to store an environment in a reader monad, and use
> local to update the environment at a let expression.  Couldn't figure
> it out, though.  Any ideas?

Hi Matt,

I am not very familiar with Multiplate, but from what I can see it
doesn't seem like this will work.  The code for traversing Let looks

  Let <$> decl child d <*> expr child e

The call to 'decl child d' can certainly have some sort of
side-effects which can influence the processing of e -- but
intuitively it seems to me there is no way to *localize* the effects
only to e; it will also affect everything processed afterwards.

If you really do want to compute free variables (not just test the
limits of Multiplate), you may be interested in taking a look at



More information about the Haskell-Cafe mailing list