[Haskell-cafe] Explicitly passing an argument to an arrow
es at ertes.de
Wed Oct 3 14:11:12 CEST 2012
Alfredo Di Napoli <alfredo.dinapoli at gmail.com> wrote:
> Thanks Brent, this should do the trick, although what I was asking was
> something more general:
> For "explicitly pass" I meant passing them without the eta reduce, in
> other terms:
> swapA' :: (Arrow a) => a ((b,c), (b,c)) (c,b)
> swapA' t = (????) swapFirst >>> swapSecond (???)
> swapFirst = first $ arr snd
> swapSecond = second $ arr fst
> where the question marks indicate that I don't know how to tell
> swapFirst "hey, even though from the outside
> I'm passing you a tuple *t*, you have to take as input a (t,t)."
> Hope this is clearer or it has some sense at all, maybe I'm not
> getting correctly the way arrows work!
Perhaps arrow notation (Arrows extension) is what you want:
swapA' :: (Arrow a) => a ((b, c), (b, c)) (c, b)
proc ((_, x), (y, _)) -> id -< (x, y)
But I really don't understand why you're implementing this as an arrow
computation. A simple function would do the trick, and should you
really want to use it in an arrow you can just lift it by applying
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Haskell-Cafe