Proposal: Add Compositor class as superclass of Arrow

apfelmus apfelmus at
Sun Oct 21 16:04:38 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'd opt for more research for that proposal to answer the following 
essential questions:
- Do the classes correspond to already-known categories, i.e. are the 
class names optimal?
- What laws do we expect to hold?
- Are the signatures minimal, i.e. does there exist a smaller set of 
combinators that still achieves the intended effect? Are the signatures 
complete, i.e. can the intended effect always expressed with the given 
- Plenty and useful examples? At least enough examples that fit in the 
fine grained hierarchy but cannot be fit into a coarser grained one so 
as to demonstrate the necessity of a fine grained hierarchy.

These questions likely have nice answers for many of the classes, but 
CategoryZero, CategoryPlus, CategoryChoice and in particular CategoryFun 
may be hard nuts.

Also, the proposed subclass chain InvArrow => RefArrow => FunArrow may 
be cumbersome in practice since it would mean to define three functions 
instead of just  arr  when declaring an Arrow.

Btw, a better implementation type for functional references / lenses is

   Lens s a = Lens { focus :: s -> (a, a -> s) }

since that allows a more efficient implementation of modify than

   modify f s = put (f (get s)) s

The latter deconstructs  s  twice whereas the  focus  primitive works 
like a zipper.


More information about the Libraries mailing list