data Tree a = Leaf | Node a (Tree a) (Tree a)

main = (print . sum_ . map_ double . upto) (1,10)

sum_ (Node n t0 t1) = n + sum_ t0 + sum_ t1
sum_ Leaf = 0

map_ f Leaf = Leaf
map_ f (Node n t0 t1) = Node (f n) (map_ f t0) (map_ f t1)

upto (m,n) = upto' m
  where
    upto' m = if m>n then Leaf else let { t' = upto' (m+1) } in Node m t' t'

double x = x + x

