Learning Haskell with the help of trees

Hi, I am beginning to learn Haskell, and I decided to try to implement a tree. Its code is available at https://gist.github.com/anonymous/dd3eaa8bc36025d7751c I would need some help with implementing the delete element procedure. I have a feeling I am doing something very unhaskelly there. Also, when deleting a node having two children, how do I run two actions (swap the values and delete the successor)? Also, I would be delighted if you could take a look on the style and similar aspects, as they are best addressed at the beginning. Thanks, Michal

In order to implement delete you need to have some sort of merge operation
for the cases where the node being deleted has more than one child. In this
case your tree data structure doesn't appear to be a search tree or
balanced in any way so it's much harder to generally decide how delete
should work.
On Sat, May 10, 2014 at 5:05 AM, Michal Kawalec
Hi,
I am beginning to learn Haskell, and I decided to try to implement a tree. Its code is available at https://gist.github.com/anonymous/dd3eaa8bc36025d7751c
I would need some help with implementing the delete element procedure. I have a feeling I am doing something very unhaskelly there. Also, when deleting a node having two children, how do I run two actions (swap the values and delete the successor)?
Also, I would be delighted if you could take a look on the style and similar aspects, as they are best addressed at the beginning.
Thanks, Michal
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On 10.05.2014 16:27, Bob Ippolito wrote:
In order to implement delete you need to have some sort of merge operation for the cases where the node being deleted has more than one child. In this case your tree data structure doesn't appear to be a search tree or balanced in any way so it's much harder to generally decide how delete should work.
But this is a binary (albeit unbalanced, which changes nothing) tree :) Michal

Sure, but you still have to make some arbitrary decisions that define the
strategy for making one tree out of two. It's harder when the data
structure doesn't make that decision for you by its definition. Write that
function and then your delete is practically finished.
On Saturday, May 10, 2014, Michal Kawalec
On 10.05.2014 16:27, Bob Ippolito wrote:
In order to implement delete you need to have some sort of merge operation for the cases where the node being deleted has more than one child. In this case your tree data structure doesn't appear to be a search tree or balanced in any way so it's much harder to generally decide how delete should work.
But this is a binary (albeit unbalanced, which changes nothing) tree :)
Michal

On 05/10/2014 02:05 PM, Michal Kawalec wrote:
Hi,
I am beginning to learn Haskell, and I decided to try to implement a tree. Its code is available at https://gist.github.com/anonymous/dd3eaa8bc36025d7751c
I would need some help with implementing the delete element procedure. I have a feeling I am doing something very unhaskelly there. Also, when deleting a node having two children, how do I run two actions (swap the values and delete the successor)?
Also, I would be delighted if you could take a look on the style and similar aspects, as they are best addressed at the beginning.
Thanks, Michal
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
I started a project which aims to implement paredit-like editing functionality which effectively involves AST manipulation. The final goal is to use it in Yi but that's far off and no Yi code should be in the library itself. There is very little code as I did not have much time for it, but perhaps it something you might be interested in as practice. See [1]. It basically involves implementing the functionality seen at [2] so that editors in the future can bind keys to the functions and manipulate the AST that way. Let me know if you're interested in working on this. [1]: https://github.com/Fuuzetsu/hs-paredit [2]: http://mumble.net/~campbell/emacs/paredit.html -- Mateusz K.
participants (3)
-
Bob Ippolito
-
Mateusz Kowalczyk
-
Michal Kawalec