Haskell's Scrap Your Boilerplate (SYB) - applying transformation only once instead of everywhere

4 Jun
2013
4 Jun
'13
3:31 a.m.
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 PS: I also asked this on stackoverflow but figured that I might get a faster response here. Thank you!
4368
Age (days ago)
4368
Last active (days ago)
0 comments
1 participants
participants (1)
-
Duc le anh