Proposal: Add Compositor class as superclass of Arrow

Conal Elliott conal at conal.net
Mon Oct 22 15:05:36 EDT 2007


I like the simplicity of th Cartesian class, including definability of dup,
swap, lAssoc, rAssoc, first, and second.

I'm missing the significance of

> But IIRC, (&&&) does impose an "order of side effects" on the arguments,
so Arrows are more general (less restrictive) than cartesian categories.

Is it just that you're wondering with what class to associate the fst/&&&
and snd/&&& laws?

    fst . (f &&& g) = f
    snd . (f &&& g) = g

- Conal

On 10/18/07, apfelmus <apfelmus at quantentunnel.de> wrote:
>
> Conal Elliott wrote:
> > DeepArrow could benefit from suggestions (perhaps refactoring), and I
> would
> > appreciate such input.  In any case, I imagine there's some rich, useful
> > structure between Category & Arrow, and now would be a great time to
> explore
> > it before settling on a new class hierarchy.
>
> DeepArrow looks pretty much like a category corresponding to Arrows
> ("Freyd category" but I don't really know what that is) to me (without a
> functor  arr  that embeds the category of Haskell functions).
>
> I mean, Arrows are just computations a ~> b that allow you to keep
> around temporary variables with  first  and  second . Unfortunately, the
> Arrow class does not mention all the needed morphisms to do that since
> the  arr  function automatically carries most of them over from the
> category of Haskell functions. I have the feeling that DeepArrow wants
> to list exactly those necessary morphisms. Perhaps there is something
> more to DeepArrows, due to the normal function arrows in types, but
> maybe not since perhaps the only thing they can act on are tuples.
>
> In any case, I'd recommend rethinking DeepArrows, maybe there's some
> well-known category corresponding to them. For starters, there are
> cartesian categories, i.e. categories with products:
>
>    class Cartesian cat where
>       fst   :: cat (a,b) a
>       snd   :: cat (a,b) b
>       (&&&) :: cat c a -> cat c b -> cat c (a,b)
>
> with the conditions
>
>       fst . (f &&& g) = f
>       snd . (f &&& g) = g
>
> Besides fstA and sndA, this gives the morphisms
>
>       dupA      = id &&& id         -- the diagonal
>       swapA f   = snd f &&& fst f
>       lAssocA f = (fst f &&& fst (snd f)) &&& snd (snd f)
>       rAssocA f = fst (fst f) &&& (fst (snd f) &&& snd f)
>
> Interestingly, we already get
>
>    first :: Cartesian cat => cat a b -> cat (a,d) (b,d)
>    first f = (f . fst &&& id . snd)
>
> and  second  and that would be everything we need for arrows (besides
> arr ). But IIRC, (&&&) does impose an "order of side effects" on the
> arguments, so Arrows are more general (less restrictive) than cartesian
> categories. So, it's some (pre?)monoidal category with extra stuff
> (Freyd?), I don't know :)
>
> Also, I don't know what to do with the Haskell function arrows in the
> objects (= arguments to ~>) of DeepArrow.
>
> Regards,
> apfelmus
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20071022/30dbbb2c/attachment-0001.htm


More information about the Libraries mailing list