Does this tuple operator already exist * somewhere?

I know (||>)who does(a' * 'b) -> ('a -> b' -> 'c) -> 'c

But I found this pretty useful and thought if I had invented the wheel:

// ('a * 'a) -> ('a -> 'b) -> ('b * 'b)
let inline (|>>) (a,b) f = (f a, f b)

(* This can happen, I just discovered the function ceilhalf an hour ago!)

+5
source share
2 answers

No, it is not.

However, you will often see your option if you use FParsec. Here is the type signature in the FParsec documentation:

val (|>>): Parser<'a,'u> -> ('a -> 'b) -> Parser<'b,'u>

I think that the library has a very well thought-out set of operators that can be generalized for other purposes. A list of FParsec statements can be found here .

; |>>, , Haskell, Control.Arrow.

+4

, , map . map, , ( F<'a>, seq<'a> F #):

map : ('a -> 'b) -> F<'a> -> F<'b>

, F<'a> , map ( ):

type F<'a> = 'a * 'a
let map f (a, b) = (f a, f b)

F #, , , F # (, seq, array ..).

Haskell, @pad - , Haskell , , ( fmap Seq.map TwoElementTuple.map, - Haskellers -).

F # map , map ( , map.)

+3

All Articles