Proposal: Add Compositor class as superclass of Arrow

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Mon Oct 22 16:07:02 EDT 2007


Twan van Laarhoven wrote:
> My proposal would be the following. The important things are that:
>  1. It incorporates Conal's deep arrow,
>  2. as well as everything that is needed for functional references/lenses 
> and bijective/invertible functions.
> I have chosen to reuse prelude names where possible.

This is a rather finely grained hierarchy, but it's still too coarse
to define a category of invertible functions. That category has pairs:
it supports  first,  second  and  (***), but not  fst  and  snd.

> -- | 'cat' can work with pairs
> class Category cat => CategoryPair cat where
>      fst    :: cat (a,b) a
>      snd    :: cat (a,b) b
>      swap   :: cat (a,b) (b,a)
>      first  :: cat a b -> cat (a,c) (b,c)
>      second :: cat a b -> cat (c,a) (c,b)
>      (***)  :: cat a b -> cat c d -> cat (a,c) (b,d)

A similar problem exists with  inl  and  inr  of CategoryChoice.

[snip]
> class Category cat => CategoryAssoc cat t where
>      lAssoc :: cat (t a (t b c)) (t (t a b) c)
>      rAssoc :: cat (t (t a b) c) (t a (t b c))

This one is nice. Have you thought about other laws, in particular
the distributive laws of sums and products (Either and (,))?

> I would further propose that all classes named Category* go into 
> Control.Category, while Arrow* goes into Control.Arrow. The latter can 
> re-export the Control.Category module.

For compatibility reasons, I don't like reusing the Control.Arrow
module name.

Bertram


More information about the Libraries mailing list