什么是较短的写作方式?(\ x - > traceShow x x)`? [英] What's a shorter way of writing `(\ x -> traceShow x x )`?
本文介绍了什么是较短的写作方式?(\ x - > traceShow x x)`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
打印表达式的值是调试中常见的做法。例如,如果我有这样一段代码,那么
Printing the value of an expression is a common practice in debugging. For example, if I have a piece of code like this
my . super . cool . fUnCtIoN . chain $ value
,我试图看到 fUnCtIoN的输出。链
,我会添加
and I am trying to see the output of fUnCtIoN . chain
, I would add
my . super . cool . (\ x -> traceShow x x ) . fUnCtIoN . chain $ value
这是一个简单的任务,这样,更不用说我是否要打印许多中间结果:
which is mouthful for a simple task like this, not to mention if I want to print many intermediate results:
(\ x -> traceShow x x )
. my
. (\ x -> traceShow x x )
. super
. (\ x -> traceShow x x )
. cool
. (\ x -> traceShow x x )
. fUnCtIoN
. (\ x -> traceShow x x )
. chain
$ value
它只会看起来很糟糕。有更好的方法吗?
It would just look awful. Is there a better way to do this?
推荐答案
只需使用 traceShowId
!它正是你要求的。
Just use traceShowId
! It does exactly what you're asking for.
my . super . cool . traceShowId . fUnCtIoN . chain $ value
这篇关于什么是较短的写作方式?(\ x - > traceShow x x)`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文