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

LicenseBSD-like (see LICENSE)
MaintainerBrent Yorgey <byorgey@cis.upenn.edu>, Stephanie Weirich <sweirich@cis.upenn.edu>
PortabilityGHC only (-XKitchenSink)
Safe HaskellSafe
LanguageHaskell2010

Unbound.Util

Description

Various utilities for the Unbound library.

Synopsis

Documentation

class Foldable f => Collection f where Source #

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.

Minimal complete definition

emptyC, singleton, union, cmap

Methods

emptyC :: f a Source #

An empty collection. Must be the identity for union.

singleton :: a -> f a Source #

Create a singleton collection.

union :: Ord a => f a -> f a -> f a Source #

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

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

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

Instances

Collection [] Source #

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

Methods

emptyC :: [a] Source #

singleton :: a -> [a] Source #

union :: Ord a => [a] -> [a] -> [a] Source #

cmap :: (Ord a, Ord b) => (a -> b) -> [a] -> [b] Source #

Collection Set Source #

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

Methods

emptyC :: Set a Source #

singleton :: a -> Set a Source #

union :: Ord a => Set a -> Set a -> Set a Source #

cmap :: (Ord a, Ord b) => (a -> b) -> Set a -> Set b Source #

Collection Multiset Source #

Multisets are containers which preserve multiplicity but not ordering.

Methods

emptyC :: Multiset a Source #

singleton :: a -> Multiset a Source #

union :: Ord a => Multiset a -> Multiset a -> Multiset a Source #

cmap :: (Ord a, Ord b) => (a -> b) -> Multiset a -> Multiset b Source #

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

Combine a list of containers into one.

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

Create a collection from a list of elements.

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

Remove the Nothings from a collection.

newtype Multiset a Source #

A simple representation of multisets.

Constructors

Multiset (Map a Int) 

Instances

Foldable Multiset Source # 

Methods

fold :: Monoid m => Multiset m -> m #

foldMap :: Monoid m => (a -> m) -> Multiset a -> m #

foldr :: (a -> b -> b) -> b -> Multiset a -> b #

foldr' :: (a -> b -> b) -> b -> Multiset a -> b #

foldl :: (b -> a -> b) -> b -> Multiset a -> b #

foldl' :: (b -> a -> b) -> b -> Multiset a -> b #

foldr1 :: (a -> a -> a) -> Multiset a -> a #

foldl1 :: (a -> a -> a) -> Multiset a -> a #

toList :: Multiset a -> [a] #

null :: Multiset a -> Bool #

length :: Multiset a -> Int #

elem :: Eq a => a -> Multiset a -> Bool #

maximum :: Ord a => Multiset a -> a #

minimum :: Ord a => Multiset a -> a #

sum :: Num a => Multiset a -> a #

product :: Num a => Multiset a -> a #

Collection Multiset Source #

Multisets are containers which preserve multiplicity but not ordering.

Methods

emptyC :: Multiset a Source #

singleton :: a -> Multiset a Source #

union :: Ord a => Multiset a -> Multiset a -> Multiset a Source #

cmap :: (Ord a, Ord b) => (a -> b) -> Multiset a -> Multiset b Source #

disjoint :: Ord a => Set a -> Set a -> Bool Source #

Determine whether two sets have an empty intersection