将参数翻转到Elm函数调用

将参数翻转到Elm函数调用,elm,Elm,我正在尝试修改以使其呈现不同颜色的多个间隔: import Color exposing (red, blue, yellow) import Graphics.Element exposing (Element, color, spacer, flow, right) colors = [ yellow, red, blue ] presentColors : List Element presentColors = List.map (color ??? (spacer 30 30))

我正在尝试修改以使其呈现不同颜色的多个间隔:

import Color exposing (red, blue, yellow)
import Graphics.Element exposing (Element, color, spacer, flow, right)


colors = [ yellow, red, blue ]

presentColors : List Element
presentColors = List.map (color ??? (spacer 30 30)) colors

main : Element
main =
  flow right presentColors
但是,正如您所看到的,函数
color
首先使用color参数,因此我无法为
List.map
创建部分应用的版本

那么,如何将参数翻转到
颜色
,以便可以部分应用它呢?

转到。按在搜索框中,键入
flip
并单击。这将为您提供

翻转:(a->b->c)->b->a->c

将前两个参数的顺序翻转到函数

你可以用它来做什么

flip color (spacer 30 30)
这和

\c -> color c (spacer 30 30)

Flip在
0.19
中从elm/core中移除。您可以试试:

改为打包。

有时括号很有用。例如,
(翻转颜色)(间隔30)
。仅供参考,翻转、咖喱和未修剪已从Elm 0.19中删除。请参阅。Elm 0.19.0的已删除函数列表已移至。