任何人翻转(< $>) [英] Anyone ever flip (<$>)
本文介绍了任何人翻转(< $>)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现定义如下
(%)= flip fmap
我可以编写如下代码:
readFile / etc / passwd%lines%filter(not。null)
对我来说它更有意义那么替代
过滤器(非空)< $>行< $> readFile/ etc / passwd
显然它只是一个顺序问题,其他人是否这样做?是否有一个不写这样的代码的有效理由?
解决方案您的运算符
(%)正是操作符> (&>)
来自镜头包。
I found defining the following
(%) = flip fmap
I can write code like the following:
readFile "/etc/passwd" % lines % filter (not . null)
to me it makes more sense then the alternative
filter (not . null) <$> lines <$> readFile "/etc/passwd"
Obviously its just a matter of order, does anyone else do this? is there a valid reason not to write code like this?
解决方案 Your operator (%)
is exactly the operator (<&>)
from the lens package.
这篇关于任何人翻转(< $>)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文