Are the double forward/backward pipe operators documented?

不羁岁月 提交于 2019-12-08 18:03:35

问题


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"

回答1:


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 :-).




回答2:


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).



来源:https://stackoverflow.com/questions/2867625/are-the-double-forward-backward-pipe-operators-documented

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!