简体   繁体   English

中缀运营商的应用方式?

[英]Applicative style for infix operators?

Is there a way to make applicative uses of <$> and <*> look nice when dealing with infix operators? 在处理中缀运算符时,是否有办法使<$><*>应用程序看起来很好用? I think that 我觉得

((++) <$> a <*> ((++) <$> b <*> c ))

looks much more cluttered then 看起来更加混乱

a ++ b ++ c

so I wonder if there is a nicer way. 所以我想知道是否有更好的方式。

(<++>) = liftA2 (++)
a <++> b <++> c

or 要么

liftA2 (++) a $ liftA2 (++) b c

请参阅Thomas Davie的InfixApplicative软件包,它提供了一般的语法技巧,而不必为每次提升定义一个新的运算符。

SHE lets you write SHE让你写

(|a ++ (|b ++ c|)|)

if that's any use. 如果那是有用的。 Of course, there's some overhead to introducing a preprocessing layer. 当然,引入预处理层会有一些开销。

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

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