[Haskell-cafe] Explicitly passing an argument to an arrow

Alfredo Di Napoli alfredo.dinapoli at gmail.com
Wed Oct 3 10:41:25 CEST 2012


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 >>> swapSecond
  where
    swapFirst  = first $ arr snd
    swapSecond = 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121003/6127c310/attachment.htm>


More information about the Haskell-Cafe mailing list