3 Oct 2012 10:41
Explicitly passing an argument to an arrow
Alfredo Di Napoli <alfredo.dinapoli <at> gmail.com>
2012-10-03 08:41:25 GMT
2012-10-03 08:41:25 GMT
Hello everyone,
sorry for the dumb question but I'm wrapping my head around arrow just from this morning.
Consider this toy function to swap argument of a tuple:
swapA' :: (Arrow a) => a ((b,c), (b,c)) (c,b)swapA' = swapFirst >>> swapSecondwhereswapFirst = first $ arr sndswapSecond = second $ arr fst
It works but requires to pass a tuple of tuple, namely ((b,c), (b,c)).
How can I explicitly pass my tuple of tuple to swapFirst so I can simply invoke
swapA' (1,2)
and get the correct result?
ps. I know that swap can be easily and elegantly be written as:
swap = snd &&& fst
but the point of the exercise was to experiment with first, second and arrow concatenation
Thanks in advance,
Alfredo
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RSS Feed