【问题标题】:The meaning of |>! (forward pipe bang)|> 的含义! (前管砰)
【发布时间】:2016-06-07 20:46:03
【问题描述】:

在阅读 Websharper 在线示例时,我遇到了这样的示例:

Div [Attr.Style "padding: 5px;"] -< [
    P [Text "Type a name in the input field below:"]
    Form [
        label "First Name: "
        input
        |>! OnKeyUp (fun _ _ -> update ())
    ]
    P [
        label "Suggestions: "
        hint
    ]
]

我们似乎不在计算表达式中,并且由于某种原因,谷歌搜索|&gt;! 的含义并不是特别容易。

! 修饰符在这种情况下有什么作用?它如何改变正向管道的结果?

【问题讨论】:

标签: f# piping websharper


【解决方案1】:

谜团解开了。它不是原生 F# 运算符;它是一个 Webshaper 运算符。

来自源代码(https://github.com/intellifactory/websharper/blob/master/src/stdlib/WebSharper.Main/Pervasives.fs#L105):

/// Implements piping with mutation.
[<Inline "($f($x), $x)">]
let ( |>! ) x f = f x; x

【讨论】:

猜你喜欢
  • 2018-04-10
  • 2014-07-26
  • 2018-10-22
  • 2020-07-31
  • 2012-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多