yaya-0.1.0.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

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

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 #

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.

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

Simply cata with a carrier of 'b -> b'.