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

LicenseBSD-like (see LICENSE)
MaintainerStephanie Weirich <sweirich@cis.upenn.edu>
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Unbound.PermM

Description

A slow, but hopefully correct implementation of permutations.

Synopsis

Documentation

newtype Perm a Source #

A permutation is a bijective function from names to names which is the identity on all but a finite set of names. They form the basis for nominal approaches to binding, but can also be useful in general.

Constructors

Perm (Map a a) 

Instances

Ord a => Eq (Perm a) Source # 

Methods

(==) :: Perm a -> Perm a -> Bool #

(/=) :: Perm a -> Perm a -> Bool #

Show a => Show (Perm a) Source # 

Methods

showsPrec :: Int -> Perm a -> ShowS #

show :: Perm a -> String #

showList :: [Perm a] -> ShowS #

Ord a => Monoid (Perm a) Source #

Permutations form a monoid under composition.

Methods

mempty :: Perm a #

mappend :: Perm a -> Perm a -> Perm a #

mconcat :: [Perm a] -> Perm a #

single :: Ord a => a -> a -> Perm a Source #

Create a permutation which swaps two elements.

compose :: Ord a => Perm a -> Perm a -> Perm a Source #

Compose two permutations. The right-hand permutation will be applied first.

apply :: Ord a => Perm a -> a -> a Source #

Apply a permutation to an element of the domain.

support :: Ord a => Perm a -> [a] Source #

The support of a permutation is the set of elements which are not fixed.

isid :: Ord a => Perm a -> Bool Source #

Is this the identity permutation?

join :: Ord a => Perm a -> Perm a -> Maybe (Perm a) Source #

Join two permutations by taking the union of their relation graphs. Fail if they are inconsistent, i.e. map the same element to two different elements.

empty :: Perm a Source #

The empty (identity) permutation.

restrict :: Ord a => Perm a -> [a] -> Perm a Source #

Restrict a permutation to a certain domain.

mkPerm :: Ord a => [a] -> [a] -> Maybe (Perm a) Source #

mkPerm l1 l2 creates a permutation that sends l1 to l2. Fail if there is no such permutation, either because the lists have different lengths or because they are inconsistent (which can only happen if l1 or l2 have repeated elements).