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 8396751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:37:09+00:00 2026-06-09T20:37:09+00:00

Sometimes I get myself using different types of trees in Haskell and I don’t

  • 0

Sometimes I get myself using different types of trees in Haskell and I don’t know what they are called or where to get more information on algorithms using them or class instances for them, or even some pre-existing code or library on hackage.

Examples:

Binary trees where the labels are on the leaves or the branches:

data BinTree1 a = Leaf | 
                  Branch {label :: a, leftChild :: BinTree1 a, rightChild :: BinTree1 a}

data BinTree2 a = Leaf {label :: a} | 
                  Branch {leftChild :: BinTree2 a, rightChild :: BinTree2 a}

Similarly trees with the labels for each children node or a general label for all their children:

data Tree1 a = Branch {label :: a, children :: [Tree1 a]}

data Tree2 a = Branch {labelledChildren :: [(a, Tree2 a)]}

Sometimes I start using Tree2 and somehow on the course of developing it gets refactored into Tree1, which seems simpler to deal with, but I never gave a lot of thought about it. Is there some kind of duality here?

Also, if you can post some other different kinds of trees that you think are useful, please do.

In summary: everything you can tell me about those trees will be useful! 🙂

Thanks.

EDIT:

Clarification: this is not homework. It’s just that I usually end up using those data types and creating instances (Functor, Monad, etc…) and maybe if I new their names I would find libraries with stuff implemented and more theoretical information on them.

Usually when a library on Hackage have Tree in the name, it implements BinTree2 or some version of a non-binary tree with labels only on the leaves, so it seems to me that maybe Tree2 and BinTree2 have some other name or identifier.

Also I feel that there may be some kind of duality or isomorphism, or a way of turning code that uses Tree1 into code that uses Tree2 with some transformation. Is there? May be it’s just an impression.

  • 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-06-09T20:37:10+00:00Added an answer on June 9, 2026 at 8:37 pm

    The names I’ve heard:

    • BinTree1 is a binary tree
    • BinTree2 don’t know a name but you can use such a tree to represent a prefix-free code like huffman coding for example
    • Tree1 is a Rose tree
    • Tree2 is isomoprhic to [Tree1] (a forest of Tree1) or another way to view it is a Tree1 without a label for the root.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The more I get into writing unit tests the more often I find myself
Sorry, really bad at explaining myself sometimes. Why don't I start from the beginning.
As I've been using Grails more and more, I find myself writing code in
Our mysql processes can sometimes get backlogged and processes begin queuing up. I'd like
We have some applications that sometimes get into a bad state, but only in
Why do visitors to my site sometimes get a download to a file instead
In Ruby on Rails, I sometimes get an error on the page as: compile
When working with ActiveMQ in Eclipse, you might sometimes get a schema parsing error
After successfully opening Pop3Folder , and retrieving messages from it, I then sometimes get
sometimes i get an error like table is marked as corrupt and shld be

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.