partial-isomorphisms-0.1: Partial isomorphisms.

Control.Isomorphism.Partial.Prim

Synopsis

Documentation

data Iso alpha beta Source

Instances

inverse :: Iso alpha beta -> Iso beta alphaSource

apply :: Iso alpha beta -> alpha -> Maybe betaSource

unapply :: Iso alpha beta -> beta -> Maybe alphaSource

class IsoFunctor f whereSource

Methods

(<$>) :: Iso alpha beta -> f alpha -> f betaSource

ignore :: alpha -> Iso alpha ()Source

(***) :: Iso alpha beta -> Iso gamma delta -> Iso (alpha, gamma) (beta, delta)Source

the product type constructor `(,)` is a bifunctor from Iso $times$ Iso to Iso, so that we have the bifunctorial map *** which allows two separate isomorphisms to work on the two components of a tuple.

(|||) :: Iso alpha gamma -> Iso beta gamma -> Iso (Either alpha beta) gammaSource

The mediating arrow for sums constructed with Either. This is not a proper partial isomorphism because of mplus.

associate :: Iso (alpha, (beta, gamma)) ((alpha, beta), gamma)Source

Nested products associate.

commute :: Iso (alpha, beta) (beta, alpha)Source

Products commute.

unit :: Iso alpha (alpha, ())Source

`()` is the unit element for products.

element :: Eq alpha => alpha -> Iso () alphaSource

`element x` is the partial isomorphism between `()` and the singleton set which contains just x.

subset :: (alpha -> Bool) -> Iso alpha alphaSource

For a predicate p, `subset p` is the identity isomorphism restricted to elements matching the predicate.

iterate :: Iso alpha alpha -> Iso alpha alphaSource

distribute :: Iso (alpha, Either beta gamma) (Either (alpha, beta) (alpha, gamma))Source

Products distribute over sums.