unbound-0.4.2: Generic support for programming with names and binders

PortabilityGHC only (-XKitchenSink)
MaintainerBrent Yorgey <byorgey@cis.upenn.edu>
Safe HaskellSafe-Inferred

Unbound.Util

Description

Various utilities for the Unbound library.

Synopsis

Documentation

class Foldable f => Collection f whereSource

Collections are foldable types that support empty, singleton, union, and map operations. The result of a free variable calculation may be any collection. Instances are provided for lists, sets, and multisets.

Methods

emptyC :: f aSource

An empty collection. Must be the identity for union.

singleton :: a -> f aSource

Create a singleton collection.

union :: Ord a => f a -> f a -> f aSource

An associative combining operation. The Ord constraint is in order to accommodate sets.

cmap :: (Ord a, Ord b) => (a -> b) -> f a -> f bSource

Collections must be functorial. The normal Functor class won't do because of the Ord constraint on sets.

Instances

Collection []

Lists are containers under concatenation. Lists preserve ordering and multiplicity of elements.

Collection Set

Sets are containers under union, which preserve only occurrence, not multiplicity or ordering.

Collection Multiset

Multisets are containers which preserve multiplicity but not ordering.

unions :: (Ord a, Collection f) => [f a] -> f aSource

Combine a list of containers into one.

fromList :: (Ord a, Collection f) => [a] -> f aSource

Create a collection from a list of elements.

filterC :: (Collection f, Ord a) => f (Maybe a) -> f aSource

Remove the Nothings from a collection.

newtype Multiset a Source

A simple representation of multisets.

Constructors

Multiset (Map a Int) 

Instances

Foldable Multiset 
Collection Multiset

Multisets are containers which preserve multiplicity but not ordering.

disjoint :: Ord a => Set a -> Set a -> BoolSource