A newbie question about Arrows.
Nicolas Oury
Nicolas.Oury@lri.fr
Mon, 6 Jan 2003 11:02:32 +0100
Hello,
I read some of the material about Arrows on www.haskell.org/arrows and
I have some questions :
* Why is made the choice to use (,) as Cartesian in first?
Can't we write something like :
class Cartesian p where
pair :: a -> b -> (p a b)
projLeft :: (p a b) -> a
projRight :: (p a b) -> b
class Cartesian pair => Arrow ar where
arr ::( ar pair a b) -> (ar pair a b)
(>>>) :: (ar pair a b) -> (ar pair b c) -> (ar pair a c)
first :: (ar pair a b) -> (ar (pair a d) (pair b d))
(The same could be said for ArrowChoice)
I think this could be more powerful and could allow a smarter
management of inputs and outputs of arrows than tuples.
I think for example to event-driven arrows : we could make a pair of
inputs without mixing the "event happened" information.
* Why is made the choice of first as being a base function?
We have
first f = f *** (arr id)
second f = (arr id) *** f
So they could be define from (***).
Moreover, the definition of f *** with first and second creates an
order in the use of the f and g (first f >>> second g) whereas it seems
that (***) is a "parallel" operator.
In an event-driven arrow we have to give the same events to f and g
even if they are independent.
Best regards,
Nicolas Oury