partial-isomorphisms-0.2.2.1: Partial isomorphisms.

Safe HaskellSafe
LanguageHaskell2010

Control.Isomorphism.Partial.Prim

Contents

Synopsis

Documentation

data Iso alpha beta Source #

inverse :: Iso alpha beta -> Iso beta alpha Source #

apply :: Iso alpha beta -> alpha -> Maybe beta Source #

unapply :: Iso alpha beta -> beta -> Maybe alpha Source #

class IsoFunctor f where Source #

Minimal complete definition

(<$>)

Methods

(<$>) :: Iso alpha beta -> f alpha -> f beta infix 5 Source #

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) gamma Source #

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 () alpha Source #

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

subset :: (alpha -> Bool) -> Iso alpha alpha Source #

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

iterate :: Iso alpha alpha -> Iso alpha alpha Source #

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

Products distribute over sums.

Orphan instances

Category * Iso Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #