Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are the double forward/backward pipe operators documented?

Tags:

f#

I remember reading about the double pipe operators -- ||> and <|| -- somewhere and now I can't remember where. I can't find them on MSDN or in the language spec. Are they documented anywhere?

Example

let print a b = sprintf "%O %O" a b
(1, 2) ||> print
// val it : string = "1 2"
like image 664
Daniel Avatar asked May 19 '10 16:05

Daniel


2 Answers

Double (forward/backward) pipe operators are documented in the list of F# operators on MSDN and are also documented as a function exported from the Core.Operators module.

This is probably automatically generated from the XML documentation in the F# sources, so the pages have somewhat cryptic names:

  • Operators.( ||> )<'T1,'T2,'U> Function (F#)
  • Operators.( <|| )<'T1,'T2,'U> Function (F#)

As a side-note, finding the operator using search engines is a bit of a problem, so I looked in the F# sources (distributed with CTP release) and the prim-types.fs includes the following:

/// <summary>Apply a function to two values, the 
///   values being a pair on the left, the function on the right</summary>
/// <param name="arg1">The first argument.</param>
/// <param name="arg2">The second argument.</param>
/// <param name="func">The function.</param>
/// <returns>The function result.</returns>
val inline (||>): arg1:'T1 * arg2:'T2 -> func:('T1 -> 'T2 -> 'U) -> 'U

I was going to recommend the F# sources as a good documentation for this kind of thing (which they certainly are), but then I pasted a part of the <summary> tag to google and found the pages mentioned above :-).

like image 176
Tomas Petricek Avatar answered Nov 17 '22 03:11

Tomas Petricek


See @Tomas' answer. The key aspect is that these are merely functions in the library, so you want to look in the library docs (and Core.Operators contains these guys).

like image 1
Brian Avatar answered Nov 17 '22 03:11

Brian