
At 2003-01-06 03:14, Ross Paterson wrote:
class PreArrow ar where arr :: (a -> b) -> ar a b (>>>) :: ar a b -> ar b c -> ar a c ... class (PreArrow ar, Monoidal p u) => GenArrow ar p u where first :: ar a b -> ar (p a c) (p b c)
My own preference is something like this: class (PreArrow ar) => GenArrow' ar where arrApply :: ar p (q -> r) -> ar p q -> ar p r My GenArrow' is actually equivalent to Hughes' Arrow and I assume your GenArrow. In an ideal world, I could leverage my FunctorApply class to have something like this: class (Functor f) => FunctorApply f where -- first arg (fab) "executed" first fApply :: f (a -> b) -> (f a -> f b) -- first arg (fa) "executed" first fPassTo :: f a -> f (a -> b) -> f b fPassTo fa fab = fApply (fmap (\a ab -> ab a) fa) fab class (PreArrow ar,forall p. FunctorApply (ar p)) => GenArrow'' ar Unfortunately, GHC does not yet allow this kind of superclassing. <http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/hbase/Source/HBa se/Category/Functor.hs?rev=HEAD&content-type=text/plain> <http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/hbase/Source/HBa se/Category/Arrow.hs?rev=HEAD&content-type=text/plain> -- Ashley Yakeley, Seattle WA

Hi, I have recently discovered Functional Programming and the Language Haskell. I was wondering if anyone could reccomend some good tutorials. Thanks.. __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com

I may be totally wrong, but I read in Hughes paper than in Stream Processors, Either is "more a product" than (,) . It could be interesting to parameter the arrow by product, in order than the multiplexing is done using this product when using the new notation for arrow. Best regards, Nicolas Oury On Mon, 6 Jan 2003, Ashley Yakeley wrote:
At 2003-01-06 03:14, Ross Paterson wrote:
class PreArrow ar where arr :: (a -> b) -> ar a b (>>>) :: ar a b -> ar b c -> ar a c ... class (PreArrow ar, Monoidal p u) => GenArrow ar p u where first :: ar a b -> ar (p a c) (p b c)
My own preference is something like this:
class (PreArrow ar) => GenArrow' ar where arrApply :: ar p (q -> r) -> ar p q -> ar p r
My GenArrow' is actually equivalent to Hughes' Arrow and I assume your GenArrow.
In an ideal world, I could leverage my FunctorApply class to have something like this:
class (Functor f) => FunctorApply f where -- first arg (fab) "executed" first fApply :: f (a -> b) -> (f a -> f b)
-- first arg (fa) "executed" first fPassTo :: f a -> f (a -> b) -> f b fPassTo fa fab = fApply (fmap (\a ab -> ab a) fa) fab
class (PreArrow ar,forall p. FunctorApply (ar p)) => GenArrow'' ar
Unfortunately, GHC does not yet allow this kind of superclassing.
<http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/hbase/Source/HBa se/Category/Functor.hs?rev=HEAD&content-type=text/plain> <http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/hbase/Source/HBa se/Category/Arrow.hs?rev=HEAD&content-type=text/plain>
-- Ashley Yakeley, Seattle WA

On Tue, Jan 07, 2003 at 06:22:53PM +0100, Nicolas.Oury wrote:
I may be totally wrong, but I read in Hughes paper than in Stream Processors, Either is "more a product" than (,) . It could be interesting to parameter the arrow by product, in order than the multiplexing is done using this product when using the new notation for arrow.
The arrow notation is closely tied to products. If you want to write an expression containing several variables, you need a tuple containing values for those variables (an environment). An asynchronous stream processor gives you a value for only one channel at a time. Bridging this gap won't be easy, but it's what Magnus is attempting in the work I referenced. Essentially he builds a tuple containing the last value received on each channel, waiting until all channels have produced.

In article <20030107180142.GA8071@soi.city.ac.uk>,
Ross Paterson
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
participants (4)
-
Ashley Yakeley
-
kunphuzil
-
Nicolas.Oury
-
Ross Paterson