简体   繁体   English

Haskell的含义是什么?

[英]What does & mean in Haskell?

I'm trying to understand an example from plotlyhs : 我试图从plotlyhs中理解一个例子:

plotly "div6"
    [points (aes & x .~ sepalLength 
                 & y .~ sepalWidth
                 & color ?~ (fromEnum . irisClass)) iris]
    & layout . margin ?~ thinMargins
    & layout . height ?~ 300

But I don't know what & means. 但我不知道是什么&手段。 Also I can't quite seem to google it. 此外,我似乎无法谷歌它。

I don't know what .~ or ?~ mean, either, but I guess I ask other questions for those. 我不知道是什么.~或者?~也就是说,但我想我会问其他问题。

More than likely, you're using the reverse function application operator , defined as 您很可能使用的是反向函数应用程序运算符 ,定义为

(&) :: a -> (a -> b) -> b
a & f = f a

It's simply a flipped version of ($) , frequently used in GUI libraries and other things where it makes sense to "apply" features and modifiers to existing values. 它只是($)的翻转版本,经常用于GUI库和其他将“应用”功能和修饰符应用于现有值的事情。

textbox & onClick foo & enabled

looks better and is often more straightforward than 看起来更好,通常比直接更直接

enabled . onClick foo $ textbox

which reads backwards, in some sense. 在某种意义上,它向后读。 To know what the line is about, you have to start from the right. 要知道这条线是什么,你必须从右边开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM