本文介绍了为什么“((subtract`))1 2"为何?失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果反勾号将前缀函数更改为infix,并且括号将其更改为前缀,则:

If back-tick changes a prefix function to infix, and parenthesis changes a infix function to prefix, then:

从语法上,为什么(`subtract`) 1 2会失败?

推荐答案

尽管反引号将前缀转换为前缀,括号将前缀转换为前缀"是方便的快捷方式,但它并不是Haskell语法的精确描述.为此,您应该转到报告,它可以清楚地表明可以放入反引号(或括号)内的内容非常受限制.反引号中唯一允许使用的是简单标识符,同样也要加上括号,以使前缀事物成为前缀.

Although "backticks turn prefix to infix and parentheses turn infix to prefix" is a convenient mental shortcut, it is not a precise description of the Haskell syntax. For that, you should turn to the Report, which makes it clear that the class of things that can go inside backticks (or parentheses) is quite restricted. The only thing allowed in backticks is simple identifiers, and likewise for the kind of parentheses that make infix things prefix.

这篇关于为什么“((subtract`))1 2"为何?失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 13:30