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

Copyright(c) Brett Wines 2014
LicenseBSD-style
Maintainerbgwines@cs.stanford.edu
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell98

Zora.Types

Description

Assorted types and typeclasses

Synopsis

Documentation

class Zoldable z where Source

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 -> m Source