Elm中双参数匿名函数的简化

Elm中双参数匿名函数的简化,elm,function-composition,Elm,Function Composition,在Elm中,如果我有一个匿名函数 (\f x -> f x) 我可以把它简化为 (<|) 我想我可以用 (f |> g) 但是编译器抱怨类型 具体地说,在我的update函数的一个例子中,我有如下内容: let msgNames = [Foo, Bar] values = ["f", "b"] // These values are actually derived // by a more complicated o

在Elm中,如果我有一个匿名函数

(\f x -> f x)
我可以把它简化为

(<|)
我想我可以用

(f |> g)
但是编译器抱怨类型

具体地说,在我的
update
函数的一个例子中,我有如下内容:

let
  msgNames = [Foo, Bar]

  values = ["f", "b"] // These values are actually derived
                      // by a more complicated operation

  model_ = List.map2 (<|) msgNames values
               |> List.foldl (\msg mod -> update msg mod |> Tuple.first)
                      model
in
  ( model_, Cmd.none )

我们可以按照以下几个步骤来简化:

(\x y->f x y |>g)
... 可以写成
(\x y->g(f x y))
... 可以写成

(\x->g谢谢。这就是我要找的。我同意
(((
let
  msgNames = [Foo, Bar]

  values = ["f", "b"] // These values are actually derived
                      // by a more complicated operation

  model_ = List.map2 (<|) msgNames values
               |> List.foldl (\msg mod -> update msg mod |> Tuple.first)
                      model
in
  ( model_, Cmd.none )
The right side of (|>) is causing a type mismatch.

159|                                      update |> Tuple.first)
                                                    ^^^^^^^^^^^
(|>) is expecting the right side to be a:

    (Msg -> Model -> ( Model, Cmd Msg )) -> a

But the right side is:

    (( Model, Cmd Msg )) -> Model