将可折叠结构展平为列表

toListFoldable 结构 t a 展平为 as 列表。

ghci> toList [7, 2, 9]  -- t ~ []
[7, 2, 9]
ghci> toList (Right 'a')  -- t ~ Either e
"a"
ghci> toList (Left "foo")  -- t ~ Either String
[]
ghci> toList (3, True)  -- t ~ (,) Int
[True]

toList 被定义为等同于:

class Foldable t where
    -- ...
    toList::t a -> [a]
    toList = foldr (:) []