Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 663077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:27:00+00:00 2026-05-13T23:27:00+00:00

I have been using uniplate and SYB and I am trying to transform a

  • 0

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.

Update:
The main reason that I need to do this is that I need to

  1. change the order of [DataB]
  2. add something to [DataB]

So if you all know a cool way to create a mkT that would match

B1:B2:B3:B4:[] (which would be per say the full list of [DataB]

and not

B2:B3:B4:[]
or any other derivations of that.

I am siding to just biting the bullet and createing the “DataBs”, data type and doing a simple mkT match on that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:27:00+00:00Added an answer on May 13, 2026 at 11:27 pm

    I wound up creating my own transformation function

    So

    dataBListTrans:: ([DataB] -> [DataB]) -> Tree -> Tree
    dataBListTrans f = transformBi $ dataAs f . (transformBi $ dataBs f)
     where
       dataAs f (DataA1 a bs) = DataA1 a (f bs)
       dataAs x = x
       dataBs f (DataB3 s bs) = DataB3 s (f bs)
       dataBs x = x
    

    It is kind of a pain to create for a larger data structure, but this was the best that I could come up with

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using a custom type for Money with my POCOs and tries
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been using PHP and JavaScript for building my dad's website. He wants
I have been using Eclipse as an IDE for a short amount of time
I have been using Castle MonoRail for the last two years, but in a
We have been using Scrum for around 9 months and it has largely been
I have been using C# for a while now, and going back to C++
I have been using ASP.NET for years, but I can never remember when using
I have been using Ruby for a while now and I find, for bigger
I have been using IoC for a little while now and I am curious

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.