Say I've got f :: u -> v -> w
and g :: x -> y -> z
. What I want is h :: (u,x) -> (v,y) -> (w,z)
.
So I could go about this manually:
h (u,x) (v,y) = (f u v, g x y)
But where's the fun in that?
Using (***)
I can get partway there:
(f *** g) :: (u,x) -> (v -> w, y -> z)
But I can't figure out how to get that final mile.
An Arrow operator in C/C++ allows to access elements in Structures and Unions. It is used with a pointer variable pointing to a structure or union.
The (->) arrow operator The -> is called the arrow operator. It is formed by using the minus sign followed by a greater than sign. Simply saying: To access members of a structure, use the dot operator. To access members of a structure through a pointer, use the arrow operator.
Thus they created dynamically. We cannot name an arrow function as we do for the regular functions. However, if you'd like to call or reuse an arrow function, you will need to assign it to a variable. Arrow functions are always anonymous.
Arrow Operator in C++ In C++ . is the standard member access operator. It has higher precedence than the * dereference operator. Accessing the member of an object through a pointer requires dereferencing to happen first, so the dereferencing operation must be wrapped in parentheses.
(***) :: (Arrow a) => a b c -> a b' c' -> a (b, b') (c, c')
So specialize a to ->
and we get:
(***) :: (Arrow a) => (b -> c) -> (b' -> c') -> (b, b') -> (c, c')
And that's great, except we want to, for whatever reason, take the first two arguments as a single pair instead. But that's easy, we just uncurry.
Prelude Control.Arrow> :t uncurry (***)
uncurry (***) :: (Arrow a) => (a b c, a b' c') -> a (b, b') (c, c')
And if you specialize the a
again, you should see the type signature you were looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With