
8 Jan
2017
8 Jan
'17
8:06 p.m.
Hi, I’m rapidly descending into a spiral of confusion! :) How do I add something to a rose tree? I have data Tree a = Node a [Tree a] deriving (Show) add :: Eq a => a -> a -> Tree a -> Tree a and the first ‘a’ is the thing to add and the second is its parent node. i.e. add :: Eq a => a -> a -> Tree a -> Tree a add x px (Node x' []) = Node x' [Node x []] ….. I’ve tried various ways for the more general case but always seem to lose part of the tree. Any advice would be very welcome. Thanks Mike