• #### why a0 do not accept any type

From meInvent bbird@21:1/5 to All on Tue Jul 26 18:56:53 2016
do i need to explicit to define the type it use for the tree?
and how to do?

if there are many kind of labeled tree (Num , XXXX)
there will be many repeated code to define a new labeled tree

is there any template type that fit for labeled tree

let aa = [(1,MA), (2,MB), (3,MC), (4,MD), (5,ME), (6,MF), (7,MG), (8,MH)]
let aatree = treeToList aa

*Main> let aatree = treeToList aa

<interactive>:4:25:
Couldn't match expected type `BTree a0'
with actual type `[(Integer, Operation)]'
In the first argument of `treeToList', namely `aa'
In the expression: treeToList aa
In an equation for `aatree': aatree = treeToList aa
*Main> treeToList aa

<interactive>:5:12:
Couldn't match expected type `BTree a0'
with actual type `[(Integer, Operation)]'
In the first argument of `treeToList', namely `aa'
In the expression: treeToList aa
In an equation for `it': it = treeToList aa

data BTree a = EmptyTree
| NNode a (BTree a) (BTree a)
deriving (Show)

treeFromList :: (Ord a) => [a] -> BTree a
treeFromList [] = EmptyTree
treeFromList (x:xs) = NNode x (treeFromList (filter (<x) xs))
(treeFromList (filter (>x) xs))

treeToList :: (Ord a) => BTree a -> [a]
treeToList EmptyTree = []
treeToList (NNode root left right) = treeToList left ++ [root] ++ treeToList right

--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)