I would like to create a function map3 that, given a function f and a tuple (a, b, c) applies f to every member of the tuple. The expected signature of the function should be:
('a -> 'b) -> 'a * 'a * 'a -> 'b * 'b * 'b .
I tried several approaches:
> let map3 = fun x -> let f = fun (a, b, c) -> (a, b, c) in f x;;
val map3 : 'a * 'b * 'c -> 'a * 'b * 'c
> let map3 = fun x y -> x (let f = fun (a, b, c) -> (a, b, c) in f y);;
val map3 : x:('a * 'b * 'c -> 'd) -> 'a * 'b * 'c -> 'd
> let map3 = fun (x, y, z) -> let f = fun (a, b, c) -> (a, b, c) in f (x, y, z);;
val map3 : x:'a * y:'b * z:'c -> 'a * 'b * 'c
I strongly suspect that I did not get how function signatures actually work. According to what I get, map3 should have one input and one output, and f should take as input a triple and return a triple. But it is clearly wrong on something. What am I missing, in my attempts to implement it?