A newbie question about Arrows.

Ashley Yakeley ashley@semantic.org
Wed, 08 Jan 2003 18:55:34 -0800


In article <20030107180142.GA8071@soi.city.ac.uk>,
 Ross Paterson <ross@soi.city.ac.uk> wrote:

> The arrow notation is closely tied to products.

Perhaps, but it doesn't have to be part of the class. I prefer this, for 
aesthetic reasons:

  class Arrow a where
     arr :: (b -> c) -> a b c
     (>>>) :: a b c -> a c d -> a b d
     arrApply :: a b (c -> d) -> a b c -> a b d

>From this one can derive:

  proj1 (b,d) = b
  proj2 (b,d) = d
  product c d = (c,d)

  arrProduct :: (Arrow a) => a b c -> a b d -> a b (c,d)
  arrProduct abc abd = arrApply (abc >>> (arr product)) abd

  -- Hughes' 'first'
  arrFirst :: (Arrow a) => a b c -> a (b,d) (c,d)
  arrFirst abc = arrProduct ((arr proj1) >>> abc) (arr proj2)

There only needs to be one class, and you can use whatever product you 
like by using the appropriate functions for 'proj1', 'proj2' and 
'product'.

<http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/hbase/Source/H
Base/Category/Arrow.hs?rev=HEAD&content-type=text/plain>

-- 
Ashley Yakeley, Seattle WA