darcs patch: Make toList a member of Foldable
ross at soi.city.ac.uk
Tue Apr 27 18:37:11 EDT 2010
On Tue, Apr 27, 2010 at 11:53:47PM +0200, Eelis van der Weegen wrote:
> Thanks a lot for mentioning the RULES pragma, which I did not know
> about. It turns out that using it to specialize Foldable's toList for
> things like NonEmptyList works like a charm.
If the existing rules don't already do this for , it needs fixing.
The instance for NonEmpty should be
instance Foldable NonEmpty where
foldr f x (NonEmpty h t) = f h (foldr f x t)
which would then rely on the optimization of the  instance.
More information about the Libraries