Proposal: refactor Arrow class

Ross Paterson ross at soi.city.ac.uk
Tue Jul 17 00:21:21 CEST 2012


On Mon, Jul 16, 2012 at 08:44:03PM +0100, Twan van Laarhoven wrote:
> I showed that the weaker isoPremap is enough for `if`, and it also
> suffices for getting `(|||)` for `left` and vice versa.

Recalling that premap f g = arr f >>> g, the translation of if is

    proc e -> if b then c1 else c2
    =>
    premap (\ e -> if b then Left e else Right e) (c1 ||| c2)

The point is that b isn't a Bool value, it's a Bool-valued expression
in the variables in the environment e.

Another sort of command one often uses is -<, with translation

    proc e -> a -< v
    =>
    premap (\ e -> v) a

Again, v is an expression in the variables in the environment e.

We need premap to evaluate expressions with respect to the tuple of
variables in the environment, and the whole point of arrow notation
is to plumb that environment through the various constructs so that
we can evaluate expressions against it (using premap).  What use
would it be otherwise?

> And I do have two use-cases for these classes, namely isomorphisms and
> lenses. I am sure there are other examples of categories for which
> `arr` is too strong, but which do, for example, support `first`. The
> current `Arrow` class is too heavy weight. We already split of
> Category, but there are more things in between it and full arrows.

You're focussing on instances, but in addition to those, a useful 
interface also needs client functions.



More information about the Libraries mailing list