
27 Apr
2010
27 Apr
'10
6:37 p.m.
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.