error: Not in scope: data constructor `BinTree'

if i compile the following code I get "bintree.hs:3:13: Not in scope: data constructor `BinTree'" data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show b1 = (Node (BinTree 3) EmptyBinTree) please help -kak

Your constructor is called Node, not BinTree.
data BinTree a = Node a (BinTree a) (BinTree a) | EmptyNode
b1 = Node 3 EmptyNode EmptyNode
-R. Kyle Murphy
Sent from my phone.
On Apr 13, 2012 12:24 PM, "Kak Dod"
if i compile the following code I get "bintree.hs:3:13: Not in scope: data constructor `BinTree'"
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = (Node (BinTree 3) EmptyBinTree)
please help
-kak
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Thank you but
if I change the code like this:
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = Node 3 EmptyBinTreeEmptyBinTree
Then I am get this error:
bintree.hs:1:23:
`BinTree' is not applied to enough type arguments
Expected kind `?', but `BinTree' has kind `k0 -> *'
In the type `BinTree'
In the definition of data constructor `Node'
In the data type declaration for `BinTree'
Failed, modules loaded: none.
________________________________
From: Kyle Murphy
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = (Node (BinTree 3) EmptyBinTree)
please help
-kak
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

"(BinTree a)" needs to be in parentheses to pattern-match properly.
data BinTree a = Node (BinTree a) (BinTree) a | EmptyBinTree
deriving Show
On 4/13/12, Kak Dod
Thank you but
if I change the code like this:
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = Node 3 EmptyBinTreeEmptyBinTree
Then I am get this error:
bintree.hs:1:23: `BinTree' is not applied to enough type arguments Expected kind `?', but `BinTree' has kind `k0 -> *' In the type `BinTree' In the definition of data constructor `Node' In the data type declaration for `BinTree' Failed, modules loaded: none.
________________________________ From: Kyle Murphy
To: Kak Dod Cc: "beginners@haskell.org" Sent: Friday, 13 April 2012 4:38 PM Subject: Re: [Haskell-beginners] error: Not in scope: data constructor `BinTree' Your constructor is called Node, not BinTree. data BinTree a = Node a (BinTree a) (BinTree a) | EmptyNode b1 = Node 3 EmptyNode EmptyNode -R. Kyle Murphy Sent from my phone. On Apr 13, 2012 12:24 PM, "Kak Dod"
wrote: if i compile the following code I get "bintree.hs:3:13: Not in scope: data constructor `BinTree'"
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = (Node (BinTree 3) EmptyBinTree)
please help
-kak
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Thanks Tom. this is what i wanted
I do not want "Node a" there, I wants only Node and Tom's solution works.
Thanks to all .
________________________________
From: Tom Murphy
Thank you but
if I change the code like this:
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = Node 3 EmptyBinTreeEmptyBinTree
Then I am get this error:
bintree.hs:1:23: `BinTree' is not applied to enough type arguments Expected kind `?', but `BinTree' has kind `k0 -> *' In the type `BinTree' In the definition of data constructor `Node' In the data type declaration for `BinTree' Failed, modules loaded: none.
________________________________ From: Kyle Murphy
To: Kak Dod Cc: "beginners@haskell.org" Sent: Friday, 13 April 2012 4:38 PM Subject: Re: [Haskell-beginners] error: Not in scope: data constructor `BinTree' Your constructor is called Node, not BinTree. data BinTree a = Node a (BinTree a) (BinTree a) | EmptyNode b1 = Node 3 EmptyNode EmptyNode -R. Kyle Murphy Sent from my phone. On Apr 13, 2012 12:24 PM, "Kak Dod"
wrote: if i compile the following code I get "bintree.hs:3:13: Not in scope: data constructor `BinTree'"
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = (Node (BinTree 3) EmptyBinTree)
please help
-kak
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

If you don't include "Node a" then there isn't any point in having the a
parameter on BinTree as it's never used unless you add another constructor
that uses it. I based the modification on the usage in your example where
you're trying to store a value of 3. Without that parameter the code
becomes:
b1 = Node EmptyBinTree EmptyBinTree
I haven't tried it, but that will also likely complain it can't deduce "a"
from the usage.
-R. Kyle Murphy
Sent from my phone.
On Apr 13, 2012 1:03 PM, "Kak Dod"
Thanks Tom. this is what i wanted I do not want "Node a" there, I wants only Node and Tom's solution works. Thanks to all .
------------------------------ *From:* Tom Murphy
*To:* Kak Dod *Cc:* Kyle Murphy ; "beginners@haskell.org" < beginners@haskell.org> *Sent:* Friday, 13 April 2012 4:53 PM *Subject:* Re: [Haskell-beginners] error: Not in scope: data constructor `BinTree' "(BinTree a)" needs to be in parentheses to pattern-match properly.
data BinTree a = Node (BinTree a) (BinTree) a | EmptyBinTree deriving Show
On 4/13/12, Kak Dod
wrote: Thank you but
if I change the code like this:
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = Node 3 EmptyBinTreeEmptyBinTree
Then I am get this error:
bintree.hs:1:23: `BinTree' is not applied to enough type arguments Expected kind `?', but `BinTree' has kind `k0 -> *' In the type `BinTree' In the definition of data constructor `Node' In the data type declaration for `BinTree' Failed, modules loaded: none.
________________________________ From: Kyle Murphy
To: Kak Dod Cc: "beginners@haskell.org" Sent: Friday, 13 April 2012 4:38 PM Subject: Re: [Haskell-beginners] error: Not in scope: data constructor `BinTree' Your constructor is called Node, not BinTree. data BinTree a = Node a (BinTree a) (BinTree a) | EmptyNode b1 = Node 3 EmptyNode EmptyNode -R. Kyle Murphy Sent from my phone. On Apr 13, 2012 12:24 PM, "Kak Dod"
wrote: if i compile the following code I get "bintree.hs:3:13: Not in scope: data constructor `BinTree'"
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = (Node (BinTree 3) EmptyBinTree)
please help
-kak
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

I wants to create things that way only,
yes, later I may add another constructor like "Leaf a"
sorry for the confusion in my question .
now i comes to know that all I wants to know was syntax of how to write "Node BinTree a" instead of "Node a BinTree a" and there was many horrorful error messages like: Expected kind `?', but `BinTree' has kind `k0 -> *'
that why i have panic that time
i was not seen that error earlier
thank you for answer
________________________________
From: Kyle Murphy
I do not want "Node a" there, I wants only Node and Tom's solution works. Thanks to all .
________________________________ From: Tom Murphy
To: Kak Dod Cc: Kyle Murphy ; "beginners@haskell.org" Sent: Friday, 13 April 2012 4:53 PM Subject: Re: [Haskell-beginners] error: Not in scope: data constructor `BinTree' "(BinTree a)" needs to be in parentheses to pattern-match properly.
data BinTree a = Node (BinTree a) (BinTree) a | EmptyBinTree deriving Show
On 4/13/12, Kak Dod
wrote: Thank you but
if I change the code like this:
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = Node 3 EmptyBinTreeEmptyBinTree
Then I am get this error:
bintree.hs:1:23: `BinTree' is not applied to enough type arguments Expected kind `?', but `BinTree' has kind `k0 -> *'
In the type `BinTree'
In the definition of data constructor `Node' In the data type declaration for `BinTree' Failed, modules loaded: none.
________________________________ From: Kyle Murphy
To: Kak Dod Cc: "beginners@haskell.org" Sent: Friday, 13 April 2012 4:38 PM Subject: Re: [Haskell-beginners] error: Not in scope: data constructor `BinTree' Your constructor is called Node, not BinTree. data BinTree a = Node a (BinTree a) (BinTree a) | EmptyNode b1 = Node 3 EmptyNode EmptyNode -R. Kyle Murphy Sent from my phone. On Apr 13, 2012 12:24 PM, "Kak Dod"
wrote: if i compile the following code I get "bintree.hs:3:13: Not in scope: data constructor `BinTree'"
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
b1 = (Node (BinTree 3) EmptyBinTree)
please help
-kak
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

On Fri, Apr 13, 2012 at 11:46 AM, Kak Dod
Thank you but if I change the code like this:
data BinTree a = Node BinTree a BinTree a | EmptyBinTree deriving Show
If you look closely, Kyle made other changes to your code as well :-) Antoine
participants (4)
-
Antoine Latter
-
Kak Dod
-
Kyle Murphy
-
Tom Murphy