4

在阅读 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
    ]
]

我们似乎不在计算表达式中,并且由于某种原因,谷歌搜索|>!.

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

4

1 回答 1

2

谜团已揭开。它不是原生 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
于 2014-04-27T15:27:09.007 回答