Proposal: Add Compositor class as superclass of Arrow

haskell at list.mightyreason.com haskell at list.mightyreason.com
Thu Oct 25 12:47:35 EDT 2007


apfelmus wrote:
> Conal Elliott wrote:
>> i'm missing a piece of reasoning.  how about having &&& as primitive
>> as in
>> your Cartesian proposal, but without the fst/&&& and snd/&&& laws?
>> you could still introduce those laws in a subclass that does not
>> include Arrow.
> 
> That would make me feel uncomfortable. At least, I'd drop the name
> "Cartesian" which intends to allude to "cartesian category".
> 
> I can't quite put my finger on it, but I think it's the following: since
> &&& is somewhat abstract, the best way to characterize it is by laws. I
> mean, it's the same for  monads  and  return . The fact that  return has
> no side-effects is captured in its entirety by the laws
> 
>   return x >>= f = f x
>   m >>= return   = m
> 
> In other words,  return  is determined uniquely by those two laws.
> Likewise, the three laws for  fst, snd  and  &&&  uniquely determine (up
> to isomorphism) the notion of "cartesian product" in any category (see
> also http://en.wikipedia.org/wiki/Product_%28category_theory%29).
> 
> If those laws don't hold, I think the most compelling characterization
> of &&& is indeed in terms of the decomposition
> 
>   f &&& g = first f . second g

I think that gets the order of side effects wrong.  I think you mean:

  f &&& g = second g . first f

(As one can see from the original class default in CategoryFanOut with CategoryPair)

> 
> and laws for the new primitives  first  and  second  like
> 
>   first  f . first  g = first  (f . g)
>   second f . second g = second (f . g)
> 
> and others.
> 
>   fst . first  f . dup = f
>   snd . second f . dup = f
>   snd . first  f . dup = fst . second f . dup
>   ...
> 
> It's already tricky to list them all, how to express the fact that
> first  and  second  pass the other value intact while still performing a
> potential side effect? And what about a minimal (but still complete)
> amount of laws?

Well, the type signature of first does not allow much to be done with the
snd argument except id.

The other tricks are: should dup have no side effects?  How to specify?



More information about the Libraries mailing list