Hi I need help in understanding this Foldable tree implementation from from here
Consider the following
import qualified Data.Foldable as F
data Tree a = Empty | Node a (Tree a) (Tree a) deriving (Show, Read, Eq)
instance F.Foldable Tree where
foldMap f Empty = mempty
foldMap f (Node x l r) = F.foldMap f l `mappend`
f x `mappend`
F.foldMap f r
I have difficulty in understanding how in this example, mempty and mappend get their implementation what their types and how they infered from for example the following invokation.
F.foldl (+) 0 testTree
Thanks