lists searches in SYB or uniplate haskell
- by Chris
I have been using uniplate and SYB and I am trying to transform a list
For instance
    type Tree = [DataA]
data DataA =  DataA1 [DataB] 
            | DataA2 String 
            | DataA3 String [DataA]
               deriving Show
data DataB =  DataB1 [DataA] 
            | DataB2 String 
            | DataB3 String [DataB]
               deriving Show
For instance, I would like to traverse my tree and append a value to all [DataB]
So my first thought was to do this:
changeDataB:: Tree -> Tree
changeDataB = everywhere(mkT changeDataB')
chanegDataB'::[DataB] -> [DataB]
changeDataB' <add changes here>
or if I was using uniplate
    changeDataB:: Tree -> Tree 
    changeDataB = transformBi changeDataB'
    chanegDataB'::[DataB] -> [DataB]
    changeDataB' <add changes here>
The problem is that I only want to search on the full list.
Doing either of these searches will cause a search on the full list and all of the sub-lists (including the empty list)
The other problem is that a value in [DataB] may generate a [DataB], so I don't know if this is the same kind of solution as not searching chars in a string.
I could pattern match on DataA1 and DataB3, but in my real application there are a bunch of [DataB]. Pattern matching on the parents would be extensive.
The other thought that I had was to create a 
data DataBs = [DataB]
and use that to transform on.  That seems kind of lame, there must be a better solution.