Quick question about Arrow statements

Say I have f :: u -> v -> w and g :: x -> y -> z . I want h :: (u,x) -> (v,y) -> (w,z) .

So, I could do it manually:

 h (u,x) (v,y) = (fuv, gxy) 

But where is the fun in this?

Using (***) , I can get the part there:

 (f *** g) :: (u,x) -> (v -> w, y -> z) 

But I can't figure out how to get this last mile.

+6
haskell arrows
source share
1 answer
 (***) :: (Arrow a) => abc -> ab' c' -> a (b, b') (c, c') 

Therefore, specialize a to -> , and get:

 (***) :: (Arrow a) => (b -> c) -> (b' -> c') -> (b, b') -> (c, c') 

And it's great if we want, for some reason, to take the first two arguments as one pair. But it’s simple, we’re just cracking down.

 Prelude Control.Arrow> :t uncurry (***) uncurry (***) :: (Arrow a) => (abc, ab' c') -> a (b, b') (c, c') 

And if you specialize a again, you should see the signature of the type you were looking for.

+13
source share

All Articles