----- Forwarded Message -----
From: bahadýr altan <doaltan@yahoo.co.uk>
To: Ozgur Akgun <ozgurakgun@gmail.com>
Sent: Sunday, 11 March 2012, 16:42
Subject: Re: [Haskell-beginners] Type Tree variables

I'm sorry if I mislead you, I think I didn't mention my problem clearly there. I'm actually stuck in the position of declaring subtrees, I couldn't find a solution to that.

My function is like

f :: Tree -> Tree

And my tree structure is like 

data Tree = Empty | Branch Integer Tree Tree 

And When I write this which I learned from you : 
(c1, c2, d1, d2, e1, e2 :: Tree)

I get error. If you tell me How should I solve that I'd appreciate.
Thanks,
Bahadir


From: Ozgur Akgun <ozgurakgun@gmail.com>
To: bahadýr altan <doaltan@yahoo.co.uk>; Haskell Beginners <beginners@haskell.org>
Sent: Sunday, 11 March 2012, 16:23
Subject: Re: [Haskell-beginners] Type Tree variables

(Replying to the list again)

On 11 March 2012 14:15, bahadýr altan <doaltan@yahoo.co.uk> wrote:
Hi, 
Thanks for your reply. I tried your solution but my function becomes  like this and it gives an error on the right side :  
function (Node a (Node b _ _) (Node c _ _))  = (Node c (Node a _ _) (Node b _ _)) 

This is not what you originally said though. If you need to refer to the subtrees, you just need to name them. (Instead of using _)

[ not a very useful function, but still: ]

f :: Tree a -> Tree a
f (Node x (Node y y1 y2) (Node z z1 z2)) = Node x (Node y y1 y2) (Node z z1 z2)
-- also think about the types: (x, y, z :: a) (y1, y2, z1, z2 :: Tree a)
 
The thing is I don't need to process the subtrees but I still have to return them as an output. I still can't do that. And I read a few chapters in LYAH, it was pretty good, I learned haskell from there. However, I think the answer of this question isn't in LYAH. 
Thanks..
Bahadir

--
Ozgur Akgun