What is the resolution to this “No Instance” error?

  • A+

I have created new type describing Binary Tree

data BinTree a = Null | Num a (BinTree a) (BinTree a) deriving (Show) 

And have created the following function:

treehandle :: BinTree a -> Bool treehandle a = True 

to check at least inputing values.

When I input value Null, program outputs result successfully, but I can't input binary tree. I try thus:

treehandle (5 (Null) (Null)) 

but obtain:

<interactive>:66:13: No instance for (Num (BinTree a1 -> BinTree a2 -> BinTree a0))   (maybe you haven't applied enough arguments to a function?)   arising from the literal ‘5’ In the expression: 5 In the first argument of ‘treehandle’, namely ‘(5 (Null) (Null))’ In the expression: treehandle (5 (Null) (Null)) 



You forgot the value constructor's name

treehandle (Num 5 (Null) (Null)) 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: