toList
flattens a Foldable
structure t a
into a list of a
s.
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
is defined as being equivalent to:
class Foldable t where
-- ...
toList :: t a -> [a]
toList = foldr (:) []