What's the best way to apply a transformation to a tree only once instead of everywhere
using SYB? For instance, in the following simplified expression, there are several instances of Var "x"
, and I want to replace the first instance with Var "y"
only.
data Exp = Var String | Val Int | Plus Exp Exp |...
myExp = Val 5 `Plus` Var "x" `Plus` Val 5 `Plus` Var "x" ...
This can't be done using the everywhere
combinator since it will try to transform all instances of Var "x"
toVar "y"
.
--
Duc A. Le