Zora-1.1.8: A library of assorted useful functions and data types and classes.

Portabilityportable
Stabilityexperimental
Maintainerbgwines@cs.stanford.edu
Safe HaskellSafe-Inferred

Zora.Types

Description

Assorted types and typeclasses

Synopsis

Documentation

class Zoldable z whereSource

Zoldable is much like Foldable, but with a crucial difference:

 foldMap :: (Foldable t, Monoid m) => (  a -> m) -> t a -> m
 zoldMap :: (Zoldable t, Monoid m) => (t a -> m) -> t a -> m

It is an augmented form -- foldMap f t is zoldMap (f . g) t where g :: t a -> a. With foldMap, you lose information that you have at the time of invocation of f: the t a; the context in which the a is enclosed is discarded. Consider the following situation: you have some tree type, e.g.

 data Tree a = Leaf a | Node a (Tree a) (Tree a)

Suppose you want to get a list of all the nodes in the tree. This is just zoldMap (x -> [x]) tree.

Methods

zoldMap :: Monoid m => (z a -> m) -> z a -> mSource