Variations of folds on Haskell Trees
问题 Given a tree defined to be: data Tree a = Leaf | Node (Tree a) a (Tree a) deriving (Eq, Show) I want to use the function: foldTree :: (b -> a -> b -> b) -> b -> Tree a -> b foldTree _ b Leaf = b foldTree f b (Node lt x rt) = f (foldTree f b lt) x (foldTree f b rt) To be able to create equivalents of the normal foldr and foldl as: foldTreeR :: (a -> b -> b) -> b -> Tree a -> b foldTreeL :: (b -> a -> b) -> b -> Tree a -> b I thought these would be fairly straightforward since their definitions