只需派生Foldable并使用现有的sum:
Foldable
sum
{-# LANGUAGE DeriveFoldable #-} data Tree a = Empty | Node a [Tree a] deriving (Eq, Show, Foldable) myNums :: (Num a) => Tree a myNums = ... main = print $ sum myNums