將可摺疊結構展平為列表

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 (:) []