Copyright | (c) 2011 diagrams-core team (see LICENSE) |
---|---|

License | BSD-style (see LICENSE) |

Maintainer | diagrams-discuss@googlegroups.com |

Safe Haskell | None |

Language | Haskell2010 |

Heterogeneous lists of monoids.

# Heterogeneous monoidal lists

The idea of *heterogeneous lists* has been around for a long time.
Here, we adopt heterogeneous lists where the element types are all
monoids: this allows us to leave out identity values, so that a
heterogeneous list containing only a single non-identity value can
be created without incurring constraints due to all the other
types, by leaving all the other values out.

Type class for heterogeneous monoidal lists, with a single method allowing construction of an empty list.

# Accessing embedded values

The relation `l :>: a`

holds when `a`

is the type of an element
in `l`

. For example, `(Char ::: Int ::: Bool ::: Nil) :>: Int`

.

Inject a value into an otherwise empty heterogeneous list.

Get the value of type `a`

from a heterogeneous list, if there
is one.

alt :: (Option a -> Option a) -> l -> l #

Alter the value of type `a`

by applying the given function to it.

# Monoid actions of heterogeneous lists

Monoidal heterogeneous lists may act on one another as you would expect, with each element in the first list acting on each in the second. Unfortunately, coding this up in type class instances is a bit fiddly.

`SM`

, an abbreviation for "single monoid" (as opposed to a
heterogeneous list of monoids), is only used internally to help
guide instance selection when defining the action of
heterogeneous monoidal lists on each other.

SM m |