yaya-0.6.2.0: Total recursion schemes.
Safe HaskellSafe
LanguageHaskell2010

Yaya.Experimental.Foldable

Description

This shows how Foldable is basically Recursive specialized to lists. The true operation of Foldable is toList.

As these few operations have the usual signatures, the rest of the type class can be implemented in the as in base.

Synopsis

Documentation

class Listable f where Source #

This class represents the ability of a structure to be converted to a list. It is equivalent to Foldable, but designed to illustrate the representation of Foldable as Recursive specialized to lists.

Methods

naturalList :: f a b -> Free (XNor a) b Source #

foldMap :: (Recursive (->) t (XNor a), Monoid m) => (a -> m) -> t -> m Source #

foldl :: (Listable f, Recursive (->) t (f a)) => (b -> a -> b) -> b -> t -> b Source #

Simply cata with a carrier of b -> b.

foldr :: (Listable f, Recursive (->) t (f a)) => (a -> b -> b) -> b -> t -> b Source #

This is simply cata applied to a list – the function is the Cons case, while the initial value is the Nil case.