For BayesHive, one of the things we need to do a lot of is program transformation. The main reason for this is to generate code to represent probability distribution functions derived from descriptions of probability models -- the models are described using code written in the probability monad, and this needs to be manipulated quite extensively to determine the PDF, which is needed for the Markov chain Monte Carlo sampling we use for estimating parameters in probability models.
Program transformation is something that Haskell is really great at, since it basically just involves pattern matching against lots of different cases of syntax trees in the language you're transforming. Unfortunately, this leads to lots of code that looks like this (picking a simple case at random):
...
case last rvs of
Observed (EApp (EApp (EVar "map") (EVar f)) (EVar nm)) -> rewriteFst f nm
_ -> rvs
...
All that stuff with EApp and EVar is the explicit AST representation of the expression map f nm in the language (Baysig) that we're manipulating.
At first, doing things like this is pretty unavoidable, but wouldn't it be nice if you could write something like this instead?
...
case last rvs of
Observed [baysig|map nm|] -> rewriteFst f nm
_ -> rvs
...